Getting a POST endpoint to work in self-hosted (WebServiceHost) C# webservice?

I think a simple code can answer all your questions Task.Factory.StartNew(()=>StartServer()); Thread.Yield(); StartClient(); void StartServer() { Uri uri = new Uri(“http://localhost:8080/test”); WebServiceHost host = new WebServiceHost(typeof(WCFTestServer), uri); host.Open(); } void StartClient() { try { WebClient wc = new WebClient(); //GET string response1 = wc.DownloadString(“http://localhost:8080/test/PutMessageGET/abcdef”); //returns: “fedcba” //POST with UriTemplate string response2 = wc.UploadString(“http://localhost:8080/test/PutMessagePOSTUriTemplate/abcdef”, JsonConvert.SerializeObject(new { … Read more