c# - OData, method get with key not found -
with code below, can hit (using fiddler):
- getcustomers via get: odata/customers
- post(customermodel customer) via post: odata/customers
- delete via delete: odata/customers(5)
the delete method :
public ihttpactionresult delete([fromodatauri] int key) { console.writeline(key); }
i hit method , key, no problem.
but don't hit method key (no problem method without key, full list) :
// get: odata/customers(5) public ihttpactionresult getcustomer([fromodatauri] int key) { console.writeline(key); }
i error (response headers via fiddler): http/1.1 404 not found
the webapiconfig :
public static class webapiconfig { public static void register(httpconfiguration config) { odatamodelbuilder builder = new odataconventionmodelbuilder(); builder.entityset<customermodel>("customers"); builder.entityset<employeemodel>("employees"); config.mapodataserviceroute( routename: "odataroute", routeprefix: "odata", model: builder.getedmmodel()); } }
the method name needs picked odata routing:
get([fromodatauri] int key)
Comments
Post a Comment