Reputation: 9411
I am calling using following request to a web service (copypaste from Chrome dev panel):
Request URL:https://localhost:44300/api/userpreferences
Request Method:POST
Status Code:405 Method Not Allowed
Request Headersview source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:51
Content-Type:application/json;charset=UTF-8
Host:localhost:44300
Origin:http://localhost:3000
Referer:http://localhost:3000/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36
Request Payloadview source
{userName:asasa, projectId:2}
projectId: 2
userName: "asasas"
to a webservice method that has such a signatue:
[HttpPost]
public replyObj setCurrentProject(string userName, int projectId)
{
/// ...
}
as you see I followed interface in every detail. If I change method to PUT, other method is called with [HttpPut] attribute even if sugnature does not match, and this config just gives me {"Message":"The requested resource does not support http method 'POST'."} contrary to what I declared.
Upvotes: 1
Views: 1104
Reputation: 2945
Recently I've faced with the same problem. It seems that your method signature doesn't match the route. Change your method to
public replyObj setCurrentProject(dynamic value)
{
/// ...
}
or you can use your appropriate class instead dynamic
Upvotes: 1