I would like to include the selfLink and navigationLink(s) in my JSON responses like this:
{
"@odata.count": 4,
"@odata.nextLink": http://example.com/v1.0/Entity?$top=2&$skip=2",
"value": [
{
"@odata.selfLink": http://example.com/v1.0/Entity(610375)",
"id": 610375,
"description": "ABCDE",
"OtherEntities@odata.navigationLink": "http://example.com/v1.0/Entity(610375)/OtherEntities"
},
{
"@odata.selfLink": "http://example.com/v1.0/Entity(602762)",
"id": 602762,
"description": "KLMNOP",
"OtherEntities@odata.navigationLink": "http://example.com/v1.0/Entity(602762)/OtherEntities",
}
}
I noticed the existence of methods like:
- builder.EntitySet("Entities").HasFeedSelfLink(...)
- LinkGenerationHelpers.GenerateSelfLink(..)
But I have no idea on how to use them or even if I should use this?
Update: I found out that it is possible to add Accept: application/json;odata.metadata=full in the HTTP header. This will give me @odata.navigationLink, @odata.id (what I meant with selfLink) and a whole bunch of other @odata metadata. This leads me to two new questions though:
- Is it possible to change the default to odata-metadata=full serverside?
- Is it possible to add a custom metadata format that allows me to only output some of these @odata metadata and if possible change the name of some of them?