none
Web Api - httppost - The requested resource does not support http method Get

    Question

  • I have created an API controller, defined with static routes, and the httppost verb as below:

    [Route("api/mycontroller/myaction")]
    [HttpPost]
    public HttpResponseMessage DoStuff(string Value1, string Value2)
    {
        //execution code
        HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "yay!");
        return response;
    }

    I call that code from powershell with invoke-restmethod:

    Invoke-Restmethod -Uri "http://locahost/api/mycontroller/myaction?value1=test1&value2=text2" -Method Post

    I get a "The Requested resource does not support http method 'Get'."  when I move this to my production server running IIS8 but works locally on my development machine.

    I have looked at some of the web.config changes, but they don't seem to make any sense since I am asking to POST and its giving me a GET error.

    Any ideas what I am missing?


    • Edited by Robin Curtis Wednesday, October 19, 2016 12:57 PM
    Wednesday, October 19, 2016 12:56 PM

Answers

  • Hi Robin Curtis,

    This forum is discussing Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    Your issue may be related to ASP.NET development, please re-post this thread to the following forum for a professional answer. Thank you very much.

    https://forums.asp.net/1246.aspx/1?Web+API

    Sincerely,

    Oscar


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Robin Curtis Thursday, October 20, 2016 7:59 AM
    Thursday, October 20, 2016 4:57 AM
    Moderator

All replies

  • Hi Robin Curtis,

    This forum is discussing Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    Your issue may be related to ASP.NET development, please re-post this thread to the following forum for a professional answer. Thank you very much.

    https://forums.asp.net/1246.aspx/1?Web+API

    Sincerely,

    Oscar


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Robin Curtis Thursday, October 20, 2016 7:59 AM
    Thursday, October 20, 2016 4:57 AM
    Moderator
  • For those Googling, it got posted over here:  https://forums.asp.net/t/2106014.aspx?Web+Api+httppost+The+requested+resource+does+not+support+http+method+Get
    Friday, March 30, 2018 8:33 PM