If you run the CRM soap library sample or "StartUp.htm" page from my last blog CRM SOAP Library - Part 2 (Project Structure) , you will get the following error.
“Sdk.Util.getClientUrl Unable to get clientUrl. Context not available.”
This is a straight forward error. The library is trying to get the CRM URL from global context or Xrm.page.Context. For development purposes, you can replace the “GetGlobalContext().getClientUrl()” line in “Sdk.Soap.min.js” with your CRM Online URL.
Now if you try to run the code after making the change, code will throw the following error.
“status: 401: Unauthorized”
It becomes a pain when you have to keep deploying Java Script resources to CRM to test them. There are hundreds of forums/blogs that talk about this problem but you can’t not see any solution.
I figured out a way around this problem with the help of “Fiddler”.So, here is hack that will allow you to run/test you web resources without deploying them in CRM.
Here is the step by step tutorial to achieve this.
- If you don't have fiddler installed already, install it.you can download it from http://www.telerik.com/download/fiddler.
- Start the fiddler and make sure “Capture Traffic” is selected in the “File” menu as shown in the screen shot below.
- Logon to your CRM organisation. I am using CRM Online for this tutorial.
- Switch to fiddler and double click on a CRM URL from the session pane as shown in the screen shot.
- In the second pane, select “Inspectors>>Cookies” as shown in the screen shot below. if the contents of cookies for the selected request does not look the same try some other URL from the session list.
- Look for “MSISAuth” in the contents and select everything from that text onwards and paste it notepad.
- Select “Tools>>Customize Rules” as shown in the screen shot below. It will open the “CustomRules.js” file.
- Search for “OnBeforeRequest(oSession: Session) function in the file and add the following code to it.
1: if (oSession.PathAndQuery=="/XRMServices/2011/Organization.svc/web") 2: { 3: //appending the cookie data for the request 4: oSession.oRequest["Cookie"] = (oSession.oRequest["Cookie"] + "; text copied in step 6" ); 5: }
- Replace the highlighted text with the text copied in step 6. Save the changes to the file.
- Open up your HTML page in VS and test it. You won’t get the unauthorised error anymore.
I am not getting mentioned error (“Sdk.Util.getClientUrl Unable to get clientUrl. Context not available.”) but instead i get
ReplyDelete1.Starting 'Early Binding' Sample
2.Starting sample by creating account.
3.Error on Create accountError: status: 0:
Hello, thanks for taking the time to view my profile. I am an academic writer from the US who enjoys finding new topics to research and write about.
ReplyDeleteMedical Assignment Help
Good way of telling, good post to take facts regarding my presentation subject matter, which i am going to deliver in my college
ReplyDeleteMatlab Symbolic Math Help
I appreciate your efforts in preparing this post. I really like your blog articles.
ReplyDeleteSPSS Factor Analysis Help
The leading assignment help UK firm offers state of the art services to its clients with a promise of delivering all the required work well within the deadline.
ReplyDeleteScience Papers Assignment Help
Things are very open and intensely clear explanation of issues. was truly information. Your website is very beneficial.
ReplyDeleteMathCad Online Project Help