ASP.NET Web API method for both GET and POST

asp.net-web-api

Solution

You can do it like this

[AcceptVerbs("Get", "Post")]
public HttpResponseMessage ExecuteCommand()
{
    // logic
}

This is possible since the constructor looks like this, and takes an array of strings.

public AcceptVerbsAttribute(
    params string[] verbs
)

Problem

I have the following method in my API: ``` [HttpGet] public HttpResponseMessage ExecuteCommand() { // logic } ``` This method currently serves only the http GET method. I would also like it to respond to http POST method - Is that possible? or do I have to duplicate the method? Thanks

Original source