Sample Code: OData Synchronous Call in CRM 2011

Just sharing the sample code to make synchronous OData call in CRM 2011.

var oDataRequestUrl = http://server/orgname/xrmservices/2011/OrganizationData.svc/ContactSet?$select=FullName

var result = syncODataCall(oDataRequestUrl);

// function to make synchronous oData call
 function syncODataCall(odataSelect) {
 var request = new XMLHttpRequest();"GET", odataSelect, false);
 request.setRequestHeader("Accept", "application/json");
 request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
 var objJQuery = jQuery.parseJSON(request.responseText);
 return objJQuery.d

Check for following methods to parse the result returned

  • ProcessReturnedEntities(data.d.results)
  • ProcessReturnedEntity(data.d)

Hope it helps !

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

Please share your thoughts

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.