As part of an integration project, I need a PHP website to be able to both read from and write to Microsoft Dynamics NAV 2016's Odata services.
Microsoft Dynamics NAV 2016 uses the Odata v3 standard.
Now, let's take my customer
service as an example.
Fetching an overview of my collection of customer
entities works fine, using a link with the following format :
https://<Server>:<WebServicePort>/<ServerInstance>/OData/Company(\'<CompanyName>\')/customer
Fetching a single customer
entity based on id
works fine, using a link with the following format :
https://<Server>:<WebServicePort>/<ServerInstance>/OData/Company(\'<CompanyName>\')/customer(\'<Id>\')
Getting an overview of the $metadata
for all of my services works fine (although it's lacking Json support), using a link with the following format :
https://<Server>:<WebServicePort>/<ServerInstance>/OData/$metadata
Now, based on both the Odata v3 specs and the value of the odata.metadata
property of my customer overview service, I would expect to be able to get an overview of the $metadata
of the customer
entity, using a link with the following format :
https://<Server>:<WebServicePort>/<ServerInstance>/OData/$metadata#customer
This doesn't work as expected. See sub-section The issue
below.
Similarly, based on both the Odata v3 specs and the value of the odata.metadata
property of my dataset when retrieving a single customer, I would expect to be able to get an overview of the $metadata
of a single field of the customer
entity, using a link with this format :
https://<Server>:<WebServicePort>/<ServerInstance>/OData/$metadata#customer/@<FieldName>
This doesn't work as expected. See sub-section The issue
below.
For some reason, everything following $metadata
appears to be ignored. This means that the last three URLs give me the exact same output, which is not what I expected.
Fetching collection-specific metadata
and Fetching entity-specific metadata
of my The context
section hereabove?As @xuzhg suggested in the comments and as is indicated by Github issues like Support Metadata as a service (#181), it appears that the Odata $metadata
are not really a dynamic service. Instead, it's just a single XML file.
This explains not only why anything after $metadata is ignored in links of format https://<Server>:<WebServicePort>/<ServerInstance>/OData/$metadata#...
, but also why it only supports XML, and not Json (unlike actual Odata services).