Reputation: 9013
I have the following web api methods:
[HttpGet]
[Route("GetUserStatus")]
public HttpResponseMessage GetUserStatus()
{
}
[HttpPost]
[Route("Send")]
public HttpResponseMessage Send(string usernameTo, string message)
{
}
when I call a GET request - it works fine. But when I try to send a POST request - I get an error:
{
"Message": "No HTTP resource was found that matches the request URI 'http://localhost:11015/api/Chat/Send'.",
"MessageDetail": "No action was found on the controller 'ChatApi' that matches the request."
}
and counter of failure calls for that method is incremented. Why so? I try the following way:
Upvotes: 0
Views: 785
Reputation: 73
I could be wrong but I think the problem is that you are packaging your parameters as a single object in Postman. You can try setting usernameTo
and message
as Params in the Postman UI OR change the input of your Send
method to a single object that contains usernameTo
and message
as properties/fields (don't forget to match the casing). I prefer the latter. Something like this:
[HttpPost]
[Route("Send")]
public HttpResponseMessage Send(MessageDetails details)
{
}
public class MessageDetails
{
public string usernameTo { get; set; }
public string message { get; set; }
}
Upvotes: 2