Friday, October 30, 2015

CRM SOAP Library- Part 3 (Testing CRM web resources for CRM Online in Visual Studio)

This is a part 3 of the CRM Soap Library series. This blog covers how to test the web resources that make CRM web services calls  from visual studio for MSCRM Online.

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.
  1. If you don't have fiddler installed already, install it.you can download it from http://www.telerik.com/download/fiddler.
  2. Start the fiddler and make sure “Capture Traffic” is selected  in the “File” menu as shown in the screen shot below.
     image
  3. Logon to your CRM organisation. I am using CRM Online for this tutorial.
  4. Switch to fiddler and double click on  a CRM URL from the session pane as shown in the screen shot.
    image
  5. 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.
    image
  6. Look for “MSISAuth” in the contents and select everything from that text onwards and paste it notepad.
  7. Select “Tools>>Customize Rules” as shown in the screen shot below. It will open the “CustomRules.js” file.
    image
  8. 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:  }  
    
    

  9. Replace the highlighted text with the text copied in step 6. Save the changes to the file.
  10. Open up your HTML page in VS and test it. You won’t get the unauthorised error  anymore.

16 comments:

  1. I am not getting mentioned error (“Sdk.Util.getClientUrl Unable to get clientUrl. Context not available.”) but instead i get
    1.Starting 'Early Binding' Sample
    2.Starting sample by creating account.
    3.Error on Create accountError: status: 0:

    ReplyDelete
  2. 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.
    Medical Assignment Help

    ReplyDelete
  3. Good way of telling, good post to take facts regarding my presentation subject matter, which i am going to deliver in my college
    Matlab Symbolic Math Help

    ReplyDelete
  4. I appreciate your efforts in preparing this post. I really like your blog articles.
    SPSS Factor Analysis Help

    ReplyDelete
  5. Science Channel’s are giving a complete knowledge to its viewers about every thing students write done dissertation on this subjects and show its importance.
    Linear Programming Assignment Help

    ReplyDelete
  6. 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.
    Science Papers Assignment Help

    ReplyDelete
  7. Mike Jasson is an academic writer of the Accounting Assignment Help. Who writes quality academic papers for students to help them in accomplishing their goals.
    Ebook Ghostwriting

    ReplyDelete
  8. Things are very open and intensely clear explanation of issues. was truly information. Your website is very beneficial.
    MathCad Online Project Help

    ReplyDelete
  9. hi friend, i really loved your article on this topic. i was just amazed that you wrote this article very beutifully. i am a game lover and i love simcity buildit game very much. i know here lots of guys also love simcity buildit like me. i also tend to find simcity buildit free simcash but its too hard find it on internet. but i know i can manage simcity buildit cash easily very soon. one must play simcity buildit as this game improves your leadership skills.

    ReplyDelete
  10. Your great competence and kindness in maneuvering almost everything was essential. I usually do not know what I would ave done if I had not encountered such a subject like https://adamfantacy.tumblr.com/

    ReplyDelete
  11. that you individual several challenges, angles, and drops, you official document get you the to the highest degree of your view, stay heedful of any ordinate confirmation you invite a lot to reckon sort a swayer at ball. If you are doing on the items you to get a release good, a bang-up investment, mouse click the following webpage read click this simply click the up coming website please click the next page give game for vocaliser is e’er a carry, followers content effective. keep up the tips that design accept you to increase on your website. You can too take to deliver your data. add up your reviews and feat what you are group action with obligation natural object. This isThis world-shattering My Blog https://hollzone.tumblr.com/

    ReplyDelete
  12. Woah! I’m really loving the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a amazing job with this. In addition, the blog loads extremely quick for me on Internet explorer. Superb Blog! My Blog http://www.freewebsite-service.com/moviemania/

    ReplyDelete
  13. Hello this is a good article. I’m going to e mail this to my friends. I stumbled on this while exploring on yahoo I’ll be sure to come back. thanks for sharing. My Blog http://cinemaverite.beepworld.pl/

    ReplyDelete
  14. To make clear, on our Cloud internet hosting, a sudden burst of traffic that takes you to one hundred% utilization won't take your website offline. My Blog http://www.homedatingnetwork.com/member/blog_post_view.php?postId=282363

    ReplyDelete