Access denied in MS CRM 2011 Java script Web service call
-
2011. szeptember 8. 14:43
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
Az összes válasz
-
2011. szeptember 8. 15:18Moderátor
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!- Szerkesztette: Jamie MileyMVP, Moderator 2011. szeptember 8. 15:20
-
2011. szeptember 9. 5:48
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/- Válasznak javasolta: Amreek Singh 2011. szeptember 9. 5:48
-
2011. szeptember 9. 14:14
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 -
2011. szeptember 10. 11:53
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/- Válasznak javasolta: Amreek Singh 2011. szeptember 10. 11:53
-
2012. február 20. 15:59ModerátorDid 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! -
2012. április 24. 7:52
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.
-
2012. június 27. 10:53
Saurabh,
It seems to be a cross domain issue.Kindly do this n your IE Settings.
- Válasznak javasolta: Shantnu Sharma 2012. június 27. 10:53
- Megjelölte válaszként: RhettClintonMVP, Moderator 2013. január 4. 10:31
-
2012. július 4. 10:42
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
-
2012. július 4. 10:43
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
-
2012. július 4. 11:08
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".
- Válasznak javasolta: san Sanz 2012. július 4. 11:10
-
2012. július 7. 10:23Válaszadó
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.
-
2012. július 9. 18:25
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?
-
2012. július 10. 14:12
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"
- Válasznak javasolta: vicky_smag (Vikranth Pandiri) 2012. július 10. 14:12
- Megjelölte válaszként: RhettClintonMVP, Moderator 2013. január 4. 10:31