How can I create using C# and HttpClient the following POST request:
I need such a request for my WEB API service:
[ActionName("exist")]
[System.Web.Mvc.HttpPost]
public bool CheckIfUserExist([FromBody] string login)
{
bool result = _membershipProvider.CheckIfExist(login);
return result;
}
You could do something like this
And then strReponse should contain the values returned by your webservice
Below is example to call synchronously but you can easily change to async by using await-sync:
There is an article about your question on asp.net's website. I hope it can help you.
How to call an api with asp net
http://www.asp.net/web-api/overview/advanced/calling-a-web-api-from-a-net-client
Here is a small part from the POST section of the article
The following code sends a POST request that contains a Product instance in JSON format: