The Microsoft Graph API is based on OData and each object has an @odata.type
Looking at the user resource type, the @odata.type
is #microsoft.graph.user"
{
"@odata.type": "#microsoft.graph.user",
"id": "String (identifier)",
"deviceEnrollmentLimit": 5
}
But the example from group resource type the @odata.type
is microsoft.graph.user
and does not start with a #
{
...
"members": [ { "@odata.type": "microsoft.graph.directoryObject" } ],
"membersWithLicenseErrors": [{"@odata.type": "microsoft.graph.user"}],
...
}
The Types section of the OData Version 4.0 Common Schema Definition Language (CSDL) doesn't seem to indicate any standard related to this topic.
Question: Is the #
character part of the Microsoft defined @odata.type
or part of OData spec or just a convention some OData providers use?
I wish there was an easy answer to this question. The OData specification that describes the OData JSON format has the following to say:
For payloads described by an OData-Version header with a value of 4.0, this name MUST be prefixed with the hash symbol (#); for non-OData 4.0 payloads, built-in primitive type values SHOULD be represented without the hash symbol, but consumers of 4.01 or greater payloads MUST support values with or without the hash symbol.
The beta version of Microsoft Graph supports 4.01, but most of the V1.0 API uses 4.0. The best option would be to always include the hash symbol for non-primitive types.