locked
CRM 2011: Calling external REST web service from crm form through jQuery RRS feed

  • Question

  • Hi,

    I was trying to call a external REST WCF service from crm form onLoad event to validate the city using the following source code, the exact code worked well in a testing aspx page, however when I put it into crm web resource, it doesn't work, didn't even hit the service code when debugging, by the way I can run jQuery to access dynamics crm 2011 REST endpoint i.e. create new account record with no problem in the same place from crm form event. Any help will be greatly appreciated!

     

     

    try

    {

    $.ajax({ 

           type: 'GET',

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

           datatype: 'json',

           url: 'http://dev/Service.svc/pcres/miami',

           processdata: false,

           success: function (msg) {

                    alert('success');

           },

           error: function(err) {

                    alert('error');

           }

       });

    }

    catch(e)

    {

          alert( 'catch' + e.description);

    }

     

     



    Thursday, July 28, 2011 3:36 PM

Answers

  • Thanks Daemon! It makes sense, afterall, when accessing CRM outlook client throught OWA, same security consideration should apply.

    I found a workaround already so you can external web service through form event on CRM client side, hopefully next dynamics crm release can provide better OOB solution for this.

    Frank

    • Marked as answer by .frank Friday, September 30, 2011 3:11 PM
    Monday, August 8, 2011 6:45 PM

All replies

  • I recommend Fiddler (or some equivalent http sniffer) to trace what actually happens when the  - it almost always helps debug issues related to SOAP, AJAX, WCF, etc - especially if it works for CRM REST calls, but fails for your custom REST service.

    http://www.fiddler2.com/fiddler2/

    Ken

    Wednesday, August 3, 2011 5:17 AM
  • Accessing external WCF Service is a acrossing domain access via json, for the security consideration, it is forbidden by browser.


    daemon lin
    Wednesday, August 3, 2011 5:55 AM
  • Thanks Daemon, what about CRM outlook client, is it forbidden too?

    Frank

    Friday, August 5, 2011 3:14 PM
  • hi, frank, i think it is forbidden too
    daemon lin
    Saturday, August 6, 2011 12:57 PM
  • Thanks Daemon! It makes sense, afterall, when accessing CRM outlook client throught OWA, same security consideration should apply.

    I found a workaround already so you can external web service through form event on CRM client side, hopefully next dynamics crm release can provide better OOB solution for this.

    Frank

    • Marked as answer by .frank Friday, September 30, 2011 3:11 PM
    Monday, August 8, 2011 6:45 PM
  • Hi Frank

    I have very similar requirement in which I have to call external REST endpoint from CRM web resource.

    Can u please share the work around!!

    Regards

    Karan

    Wednesday, February 29, 2012 10:29 AM
  • what was your work around? the only way i got it to work is creating a costum security level for IE, whay is not so cool.

    Cheers

    Wednesday, July 11, 2012 8:58 PM