I ran into an odd problem today. I am upgrading our on-premise CRM environment to CRM 2013. I have some client-side code that uses the OrganizationData.svc to fetch some data from a related Opportunity entity, as follows:

}

function PopulateOpportunityData(oppId){

var ODataHost = location.protocol + ‘//’ + location.host + ‘/’ + Xrm.Page.context.getOrgUniqueName();

var ODataService = “/XRMServices/2011/OrganizationData.svc”;

var ODataQuery = “/OpportunitySet?$select=EstimatedCloseDate,Description&$filter=OpportunityId eq guid’” + oppId.toString() + “’”;

var ODataURL = ODataHost + ODataService + ODataQuery;

$.ajax({

type: “GET”,

contentType: “application/json; charset=utf-8”,

datatype: “json”,

url: ODataURL,

beforeSend: function (XMLHttpRequest) {

XMLHttpRequest.setRequestHeader(“Accept”, “application/json”);

},

success: function (data, textStatus, XmlHttpRequest) {

alert(“OData Execution Success”);

},

error: function (XmlHttpRequest, textStatus, errorObject) {

alert(“OData Execution Error Occurred”);

}

});

}

This works just fine over HTTP, but our company is implementing CRM over SSL/HTTPS only. When I run the page using HTTPS, I get the following error: Not Found.

In fact when I paste the OData Query URL into my web browser, it gives me the same error.

But over HTTP, it resolves just fine.

I looked at my IIS configuration and noticed that my HTTPS binding did not contain a host name.

But when I tried to modify it, the host name field was disabled.

I did some more research and discovered that there is an appcmd that will allow you to specify the host name from the command line:

You will need to run CMD as an Administrator and paste in the following command:

C:\Windows\System32\Inetsrv\appcmd set site /site.name:”Microsoft Dynamics CRM” /bindings.[protocol=’https’,bindingInformation=’*:443:’].bindingInformation:*:443:crm.yourhostname.com

Microsoft Dynamics CRM refers the name of the web site.

crm.yourhostname.com refers to your host name.

After I run the command, I notice that my host name is correctly set for the HTTPS binding.

Make sure you do an IISRESET.

And if that doesn’t work, then remove the HTTP binding and readd it and then do another IISRESET.

The result? J

Advertisements