With the new web api, is it possible to use a catch all route like
routes.MapHttpRoute(
name: "name",
routeTemplate: "api/{*id}",
defaults: new { controller = "mycontroller", id = RouteParameter.Optional}
);
with the PUT method? Typically the PUT method is used like
public HttpResponseMessage Put(string id, string body)
{
...
}
where body
is the body of the PUT request. However with a catch all route, this doesn't appear to work and I'm receiving the error
{
"ExceptionType":"System.ArgumentException",
"Message":":"No 'MediaTypeFormatter' is available to read an object of type 'String' with the media type ''undefined''.",
"StackTrace":"..."
}
where my put method looks like
public HttpResponseMessage Put(string id)
{
...
}
I figure I should be able to use the catch all route, where the route information will be passed to the id parameter, and that I should be able to access the body from the response object. Any ideas?