I am building some restful api using .net Web API V1.
We are trying to define some routing for the web api. I am having some issue in defining the route for 'Put' and 'patch'.
They have the same URL and the only different is in the HttpMethod. In the HttpMethod, there is no support for Patch http://msdn.microsoft.com/en-us/library/system.net.http.httpmethod(v=vs.118).aspx
config.Routes.MapHttpRoute(
"UpdateCustomer",
"api/customers/id/{id}",
new {controller = "Customers", action = "UpdateCustomer"},
new {id = @"\d+", httpMethod = new HttpMethodConstraint(HttpMethod.Put)}
);
config.Routes.MapHttpRoute(
"PatchCustomer",
"api/customers/id/{id}",
new {controller = "Customers", action = "PatchCustomer"},
new {id = @"\d+", httpMethod = new HttpMethodConstraint(HttpMethod.**Patch**)}
);
EDIT: Update to the latest version of WebAPI currently 5.2.7 (https://www.nuget.org/packages/Microsoft.AspNet.WebApi/)
ORIGINAL:
If you cannot use instead:
new HttpMethod("PATCH")
See the following example use in Web API source code
https://github.com/aspnetwebstack/aspnetwebstack/blob/master/src/System.Web.Http/HttpPatchAttribute.cs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With