Error : Url does not contain MSCRMServices

I got this error while using Accessing Microsoft Dynamics CRM Web Services from onload of lead entity.

I used the sample given in SDK which calls the WhoAmI message with the Execute method to retrieve the ID of the current user.

Resolved the error by replacing the url‘POST’, SERVER_URL +’/mscrmservices/2007/crmservice.asmx’, false);

to“POST”,  “http://myServerName:Port/MSCrmServices/2007/CrmService.asmx”, false);

SERVER_URL  global variable actually returns

http://myServerName:Port/organizationname because of which we got the error.

Here is the final code that I used

//Define the soapBody for the WhoAmI request.

var soapBody = “<soap:Body><Execute xmlns=’’><Request xsi:type=’WhoAmIRequest’ /></Execute></soap:Body>”;

//Wrap the Soap Body in a soap:Envelope.

var soapXml = “<soap:Envelope xmlns:soap=’; xmlns:xsi=’; xmlns:xsd=’’>&#8221;;

soapXml += GenerateAuthenticationHeader();

soapXml += soapBody;

soapXml += “</soap:Envelope>”;

// Create the XMLHTTP object for the execute method.

var xmlhttp = new ActiveXObject(“Msxml2.XMLHTTP”);“POST”, http://d-3638:5555/MSCrmServices/2007/CrmService.asmx&#8221;, false);

xmlhttp.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);


//Send the XMLHTTP object.


// Create an XML object to parse the results.

xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”);



// Get the user’s ID.

var userid = xmlDoc.getElementsByTagName(“UserId”)[0].childNodes[0].nodeValue;


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

One thought on “Error : Url does not contain MSCRMServices”

Please share your thoughts

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.