With the code below, I 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 look like :
public IHttpActionResult Delete([FromODataUri] int key)
{
Console.WriteLine(key);
}
I hit the method and I get the key, no problem.
But I don't hit the get method with the key (no problem with the get method without the key, I get the full list) :
// GET: odata/Customers(5)
public IHttpActionResult GetCustomer([FromODataUri] int key)
{
Console.WriteLine(key);
}
I get this error (Response headers via Fiddler): HTTP/1.1 404 Not Found
The WebApiConfig is :
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());
}
}