Home > Software engineering >  Unable to inovke [HttpPost] web api
Unable to inovke [HttpPost] web api

Time:01-11

Below is my post method

[HttpPost]
    public string Happay(string fileName) 
    {
        //some code
    }

When I try to invoke it from postman using this URL 'https://localhost:44313/SAPAPI/Happay?fileName=Payload1' it works but when I try to do the same from the browser it give me an exception that says 'resource not found'.

I removed the [HttpPost] attribute from the top an then I was able to invoke the method from the browser.

CodePudding user response:

Add [FromBody] before the parameter.

[HttpPost]
public string Happay([FromBody] string fileName) 
{
    //some code
}

CodePudding user response:

If you are calling the url from a browser, this is a GET request. Please learn more about REST.

  • Related