I have a web api method which is as follows,
[Route("api/Nltk")]
[HttpPost]
public string Create([FromBody]string text)
{
string result = "Error";
//Assign result here
return result;
}
When I make a POST request I get 404 - File or directory not found.
error. While other methods (which are all GET methods) in the same api work just fine. For further detail http://ozgurakpinar.net/api/Nltk
is the complete url.
The following is one of the methods I've tried, so far.
var values = new Dictionary<string, string> {
{ "text", "This is a relatively short sentence." },
};
HttpClient client = new HttpClient();
var content = new FormUrlEncodedContent(values);
var result = client.PostAsync("http://ozgurakpinar.net/api/Nltk", content).Result;
Edit: After I added the FromBody attribute the method is finally called, but the value of text
is null.