You’ve probably heard that in Office 365 / SharePoint Online, the REST API service now includes support for JSON light responses, meaning that you can vary the style of the ODATA response.
Reading that post you’ll notice that the ‘shape’ of the response is also different when using the minimalmetadata
or nometadata
types;
For example, when using ODATA=verbose
, your response will look like this;
And when using ODATA=minimalmetadata
or ODATA=nometadata
, your response will look like this;
In the former, your data is returned in the response.d.results
property, and in the later it’s returned in the response.value
property.
While thats all great, what the post doesn’t mention is that when using ODATA=minimalmetadata
or ODATA=nometadata
, the ‘shape’ of failure responses is also changed.
So assuming my REST request, includes a field which doesn’t exist (an easy example) and I’m using ODATA=verbose
, your error response will look like this;
If I’m using ODATA=minimalmetadata
or ODATA=nometadata
, your error response will look like this;
In the former, the error object is in a property named error
and in the later it’s in a property named odata.error
.
Everything else is the same, though to access the error object you have to use square bracket notation instead of dot notation, here’s a GIST demonstrating;
One thought on “Gotcha using Office 365 / SharePoint REST API and ODATA Minimal Metadata”