Access denied in MS CRM 2011 Java script Web service call
-
Thursday, September 08, 2011 2:43 PM
Hi,
I am making webservice call using below code ,the code is working fine on CRM Server but from client machine it is giving error access denied .
I think we need to pass some authentication for this call from client machine .
Any help is highly appreciated .
var odataSelect ="http://servername/organization/XRMServices/2011/OrganizationData.svc/OpportunitySet(guid'"+oppid[0].id+"')?$select=new_status"
var retrieveRecordsReq = new XMLHttpRequest();
retrieveRecordsReq.open("GET",odataSelect , false);
retrieveRecordsReq.setRequestHeader("Accept", "application/json");
retrieveRecordsReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
var temp= retrieveRecordsReq.send();
if (retrieveRecordsReq.readyState == 4 && retrieveRecordsReq.status == 200)
{
var retrievedRecords = JSON.parse(retrieveRecordsReq.responseText).d
}BR
Saurabh
All Replies
-
Thursday, September 08, 2011 3:18 PMModerator
The odata service only works from the CRM server, you cannot use it in external applications that do not reside on the same server. Also, if it is still in the CRM app, the user needs to have access to the records in CRM.
You could also use the soap service:
Jamie Miley
Check out my about.me profile!
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!- Edited by Jamie MileyMVP, Moderator Thursday, September 08, 2011 3:20 PM
-
Friday, September 09, 2011 5:48 AM
Hi
try using the /organization/XRMServices/2011/OrganizationData.svc/OpportunitySet(guid'"+oppid[0].id+"')?$select=new_status"; instead of using the full path.
second thing you can try is to get server URL from globalcontext instead of hard coding it.
I hope this helps.
Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/- Proposed As Answer by Amreek Singh Friday, September 09, 2011 5:48 AM
-
Friday, September 09, 2011 2:14 PM
Hi Jamie,
The user have full access on that record and I am calling above code from Javascript of CRM form . Not from external application .
one more intresting thing when I am using localost , the web service call is working on CRM server but it is not working from clien machine .
Do I need to pass any athentication for above request .
BR,
Saurabh
Saurabh -
Saturday, September 10, 2011 11:53 AM
If you use localhost in the url and your javascript url use servername. It will cause that error. The browser url and url in the script has to be same.
Did you try my suggestion
/organization/XRMServices/2011/OrganizationData.svc/OpportunitySet(guid'"+oppid[0].id+"')?$select=new_status";
It will work. Try using the servername in the browser, you won't get that error.
I hope this helps.
Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/- Proposed As Answer by Amreek Singh Saturday, September 10, 2011 11:53 AM
-
Monday, February 20, 2012 3:59 PMModeratorDid you find the answer to your question?
Jamie Miley
Check out my about.me profile!
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter! -
Tuesday, April 24, 2012 7:52 AM
Saurabh,
did you find a solution to your problem? I am having this same issue..am getting 'Access is denied' when trying to access both 'Organization' as well as 'OData' services via javascript on entity forms.
-
Wednesday, June 27, 2012 10:53 AM
Saurabh,
It seems to be a cross domain issue.Kindly do this n your IE Settings.
- Proposed As Answer by Shantnu Sharma Wednesday, June 27, 2012 10:53 AM
- Marked As Answer by RhettClintonMVP, Moderator Friday, January 04, 2013 10:31 AM
-
Wednesday, July 04, 2012 10:42 AM
Hi,
I had the same issue in my development environment, in IIS some time our administrator will change the IP for Hostname after installing the MS CRM. That’s why context.getserverurl() will return the different URL.
Confirm the URL if you getting this error.
Vejai SH
-
Wednesday, July 04, 2012 10:43 AM
Hi,
I had the same issue in my development environment, in IIS some time our administrator will change the IP for Hostname after installing the MS CRM. That’s why context.getserverurl() will return the different URL.
Confirm the URL if you getting this error.
Vejai SH
-
Wednesday, July 04, 2012 11:08 AM
hii ,
might be url problem,
use the helper class which i have done,it will retrieve more than 50 records also
check this http://crmjsrest.codeplex.com/
By Sanz. -- If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
- Proposed As Answer by san Sanz Wednesday, July 04, 2012 11:10 AM
-
Saturday, July 07, 2012 10:23 AMAnswerer
Hi,
Add the webservices url under trusted domain and instead of entering crm server name enter the IP address of the crm server on all the places where all you are using the server name.
Ex: http://crmserver/orgname
use like this http://192.168.1.1/orgname.
It will works fine both in the client and server machine.
Thanks & Regards, MS CRM Consultant, V.Surya.
-
Monday, July 09, 2012 6:25 PM
Hi Jamie,
The user have full access on that record and I am calling above code from Javascript of CRM form . Not from external application .
one more intresting thing when I am using localost , the web service call is working on CRM server but it is not working from clien machine .
Do I need to pass any athentication for above request .
BR,
Saurabh
SaurabhI had a similar problem as yours. Can yo check if this work around (http://support.microsoft.com/kb/896861) helps?
-
Tuesday, July 10, 2012 2:12 PM
Hi,
The problem is related to Cross Domain issue. If your end user tries to access the app using IP Address or full server url then you can see this behavior. Instead of getting server URL using context.getServerUrl(), use the following:
var serverUrl = window.location.protocol + "//" + window.location.host + "/" + context.getOrgUniqueName();
I have faced similiar issue earlier and blogged about it here:
http://howto-mscrm.blogspot.in/2011/08/cross-domain-issue-while-working-with.html
Hope it helps you ....!!! :)
Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"
- Proposed As Answer by vicky_smag (Vikranth Pandiri) Tuesday, July 10, 2012 2:12 PM
- Marked As Answer by RhettClintonMVP, Moderator Friday, January 04, 2013 10:31 AM