Reputation: 13713
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
Upvotes: 4
Views: 1502
Reputation: 13135
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
)
Upvotes: 7