1

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.

2
  • 1
    this may help : blog.dontpaniclabs.com/post/2013/01/23/… ..........System.Web.Http" and "System.Web.Mvc" have an "[HttpPost]" attribute use the "[System.Web.Http.HttpPost]" attribute Commented Apr 8, 2014 at 14:40
  • can you show your routes please? Commented Apr 9, 2014 at 12:22

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.