OData v4 error at startup: resource not found for segment No matter

I create my new v4 service and everything went well until I added a new controller for the new model / entity and received this error when starting the site for a trial run.

The controller seems to be correctly encoded, like the others.

The Customers path template in the GetFeed action in the CustomerOData controller is not a valid OData path template. Resource not found for Clients segment.

What on earth does this mean?

+5
source share
2 answers

If this happens at startup, check to see if you added the model type of your clients to the model builder at startup.

builder.EntitySet<CustomerModel>("Customers"); 

It appears that the attribute mappings are listed for the new controller, but it cannot map the Customer model type back to the set of objects.

Note: Q / A I realized this almost immediately, but I am posting here because I will probably do it again and forget what I did wrong!

0
source

This error occurs in the web API attribute routing script. The API attribute routing will check all ODataRouteAttributes for all ODataControllers found when starting the HttpConfiguration initializer.

You mentioned that the error occurred after you added a new model / object, so maybe you have two Edm models:

 ModelA, ModelB 

And EntitySet "Clients" are in only one of the models, for example ModelA.

In addition, you may have the following codes for the newly added model:

 config.MapODataServiceRoute("...", "...", ModelB); 

When launched, the web API finds the attribute:

 [ODataRoute("Customers")] public IHttpActionResult Get() { ... } 

but the Web API cannot find the Customers object installed in ModelB.

I think you can fix this by putting everything in one model.

+1
source

Source: https://habr.com/ru/post/1210585/


All Articles