Reputation: 938
ok. I'm using Web API to make AJAX requests. I'm trying to send a PUT request to an action on a controller. I'm using route attributes. When I'm sending the data as part of the route data, everything is fine and the action gets the right info. However, when I'm trying to send the data in the body, I get a 405 status ((Method is not allowed). I'm also adding the [FromBody] attribute to the parameter. Here's by jQuery call:
type: 'PUT',
url: 'api/ServerQueue/activity',
data: "=2",
success: function (xhr) {
$("#load").hide();
},
error: function () {
$("#load").hide();
}
};
Here's my action:
[Route("status/{status}")]
public string PutStatus([FromBody]int status)
{
}
I placed a "RoutePrefix" on the controller body. BTW, I'm using VS 2012. Any idea what could be the source of the problem?
Upvotes: 0
Views: 63
Reputation: 1713
Try changing the route configuration from
[Route("status/{status}")]
to
[Route("status")]
Upvotes: 0