Gotcha using Office 365 / SharePoint REST API and ODATA Minimal Metadata


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;

o365restodata-03

And when using ODATA=minimalmetadata or ODATA=nometadata, your response will look like this;

o365restodata-04

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;

o365restodata-01

If I’m using ODATA=minimalmetadata or ODATA=nometadata, your error response will look like this;

o365restodata-02

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;

Published by

Phil Harding

SharePoint Consultant, Developer, Father, Husband and Climber.

One thought on “Gotcha using Office 365 / SharePoint REST API and ODATA Minimal Metadata

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s