Access is denied error when executing datajs in wordpress

Aug 12, 2011 at 2:57 PM

Error message {"message":"Access is denied.\r\n","description":"Access is denied.\r\n","number":-2147024891} is displaying when we call the datajs OData.read() function through wordpress.

Aug 12, 2011 at 6:38 PM

Hi anishjeyanth,

Are you specifying a username and password for the endpoint you are trying to read (OData.read({ requestUri: endpoint, user: user, password: password }, success, failure);)? There are a few reasons you could be getting this error; could you send us an example of what you are trying to read?

-Beth

Aug 13, 2011 at 11:33 PM

Hi, I work with Anish and am trying to troubleshoot this also.  If we run the sample from a normal html page it works fine.  We are trying to call the datajs from within a WordPress page template.  We have added the scripts but getting an access denied error.  My theory is that there is some issue on how we are calling the javascript.  You can see the sample at http://spotonproperties.com/property-search-2/.

Aug 15, 2011 at 7:07 PM

Hi olylax21,

The error message is consistent with the message from requests blocked by the Same Orgin Policy. It looks like "//OData.defaultHttpClient.enableJsonpCallback = true;" was commented out right before OData.read is called. By default, enableJsonpCallback is set to false (see rationale here: http://datajs.codeplex.com/wikipage?title=OData%20Security&referringTitle=Documentation). To enable cross domain read operations on Jsonp enable servers, set this property to true: http://datajs.codeplex.com/wikipage?title=Cross%20Domain%20Requests&referringTitle=OData%20Networking

Please let me know if this doesn't solve your issue or if you have any further questions!

-Beth

Aug 16, 2011 at 12:17 AM

I have uncommented this line and we no longer get the access denied message. Now we get a 404 error from the OData service when sending a request. Do we need to modify our OData service to accept the JSONP requests?

From: BethMantey [email removed]
Sent: Monday, August 15, 2011 11:07 AM
To: Jeffrey La Croix
Subject: Re: Access is denied error when executing datajs in wordpress [datajs:268841]

From: BethMantey

Hi olylax21,

The error message is consistent with the message from requests blocked by the Same Orgin Policy. It looks like "//OData.defaultHttpClient.enableJsonpCallback = true;" was commented out right before OData.read is called. By default, enableJsonpCallback is set to false (see rationale here: http://datajs.codeplex.com/wikipage?title=OData%20Security&referringTitle=Documentation). To enable cross domain read operations on Jsonp enable servers, set this property to true: http://datajs.codeplex.com/wikipage?title=Cross%20Domain%20Requests&referringTitle=OData%20Networking

Please let me know if this doesn't solve your issue or if you have any further questions!

-Beth

Aug 16, 2011 at 2:48 AM

Yep! You can download the code necessary to enable Jsonp on the OData service from http://archive.msdn.microsoft.com/DataServicesJSONP. The link includes a description of the implementation and where to add the attribute after including the code provided in your project.

Aug 16, 2011 at 8:13 AM
Edited Aug 16, 2011 at 8:14 AM

Hi BethMantey,

After adding the Jsnop to the OData Service and uncommenting the OData.defaultHttpClient.enableJsonpCallback = true; now everything is working fine. Thanks for the help. keep up your good work.

-Anish

Aug 16, 2011 at 5:15 PM

Glad to hear it! Let us know if you have other questions or issues.

-Beth

Aug 18, 2011 at 12:05 PM
Edited Aug 18, 2011 at 12:06 PM

Hi BethMantey,

I have one question can you navigate to the discussion name "How to get the record count from Odata using DataJS"..

-Anish