-
I'm using a rather dynamic way to register my models. It's a a bit like shown here: https://github.com/xuzhg/WebApiSample/tree/main/v8.x/DynamicRouteSample It's all working well till I want to get my meta information. The linked project has the same problem. This will then return the following JSON: {
"@odata.context": "http://localhost:5182/v1/$metadata#People",
"value": [
{
"Id": 1,
"Name": "Chilly",
"Emails": [
"[email protected]",
"[email protected]"
]
},
{
"Id": 2,
"Name": "Mild",
"Emails": [
"[email protected]",
"[email protected]"
]
},
{
"Id": 3,
"Name": "Balmy",
"Emails": [
"[email protected]",
"[email protected]"
]
},
{
"Id": 4,
"Name": "Hot",
"Emails": [
"[email protected]",
"[email protected]"
]
}
]
} As you can see, the odata context is http://localhost:5182/v1/$metadata#People, but when I try to open this, I only get a 404 response. I'm a bit lost, not sure where to start looking.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hello @Remo, I'm not sure I understand the problem. What is that you try to open that returns a 404 response? You've said that the endpoint |
Beta Was this translation helpful? Give feedback.
@Remo thanks for the clarification. I had misunderstood the message. The
/$metadata
endpoint returns the schema of the service as defined in yourIEdmModel
. This endpoint is usually handled by a built-in controller that's registered when you callAddOData()
.However, in the project that you have linked it seems it uses custom dynamic rooting, and not the built-in one. I have not gone through the entire codebase to see what could be missing, but an easy workaround would be to add a custom route in your controller to handle the
$metadata
endpoint and return the model: