Hi everyone,
Thanks for helping in advance!
I'm struggled with the following JavaScript code on email entity:
function GetEmailQueueForCase(idCase) {
var strExpand = "$expand=accounts";
var strSelect = "$select=accounts/EmailQueueId";
var req = new XMLHttpRequest();
req.open("GET","http://dynamicscrm.com/XRMServices/2011/OrganizationData.svc/"
+ "/IncidentSet(guid'" + idCase + "')?" + strExpand + "&" + strSelect,
true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
GetEmailQueueForCaseCallback(this);
};
req.send();
This function doesn't work if I access the crm through HTTPS protocol : https://dynamicscrm.com/
the error given by crm is access denied
The code would return error at the req.open line
I did some research and it seemed to be the cross domain issue. Then I tried to use a proxy page to get around it.
I tested the proxy page and it was up and running fine so I put the .ashx file in CRM.
However, when I add it to the code:
var proxyUrl = "https://dynamicscrm.com/DotNet/proxy.ashx?";
req.open("GET", proxyUrl + "http://dynamicscrm.com/XRMServices/2011/OrganizationData.svc/"+
"/IncidentSet(guid'" + idCase + "')?" + strExpand + "&" + strSelect,
true);
It doestn't work. Although the access denied error was not happen, the xmlhttprequest() is not returning the correct data. I'm having a readystate 4 but status 500 situation or a readystate 4 but status 401
I wonder if using proxypage to get data from CRM organization data service is not allowed?
Is there another way around?
Please shed some light on my issue. Thank you very much!!