I have the following API-method:
[Route("api/xyz")]
[HttpPost]
public IHttpActionResult PostAPIXYZ() {
return Ok("ok");
}
Then calling it with:
using PainlessHttp.Http;
var config = new Configuration {
BaseUrl = "http://localhost:81",
};
HttpClient = new HttpClient(config);
var result = HttpClient.PostAsync<MyResult>("api/xyz", null).Result;
Result: Http status: LengthRequired (411)
In powershell it works ok:
> (Invoke-WebRequest http://localhost:81/api/xyz -Method POST).StatusDescription
OK
Using Http client from System.Net.Http works ok:
using System.Net.Http;
HttpClient HttpClient = new HttpClient {
BaseAddress = new Uri(http://localhost:81),
};
var result = HttpClient.PostAsync("api/xyz", new StringContent(""))
I have the following API-method:
Then calling it with:
Result: Http status: LengthRequired (411)
In powershell it works ok:
Using Http client from System.Net.Http works ok: