Thursday 21 August 2014

Reduce Payload of REST API calls using JSON Light in Office 365 SharePoint Online

 The REST API support provided by SharePoint 2013 has now been improved with the addition of support for JSON Light in Office 365 SharePoint Online. JSON Light is an open standard that allows options to be provided in the REST call header to limit the amount of metadata returned. If your solution doesn’t require all of the metadata then you can reduce the payload returned by your REST API calls by passing the one of the options.

The JSON Light options that are available are

verbose

This option returns complete metadata. The syntax for making the REST API call with this option is

headers: { "Accept": "application/json; odata=verbose" }

minimalmetadata

This option returns minimum amount of metadata. The  syntax for making the REST API call with this option is

headers: { "Accept": "application/json; odata=minimalmetadata" }

nometadata

This option reduces the size of the return payload significantly. The  syntax for making the REST API call with this option is

headers: { "Accept": "application/json; odata=nometadata" }

The odata property in the header is not mandatory and when not provided it defaults to minimalmetadata option.

Below are the responses with the payload size from making a REST API call to return list items from a list which has just the title column and 4 rows.

Option: verbose Response Size: 8496 bytes


 
Option: minimalmetadata Response Size: 2113 bytes


Option: nometadata Response Size: 1241 bytes
 
 

 


No comments:

Post a Comment