13 Replies Latest reply on Jun 18, 2012 8:43 AM by Peter Arcuri

    ajax call, setrequestheader

    Yuriy Volyanskyy

      I've run into issues implementing ajax call with request header parameters.

      The simple ajax call - when I’m not setting anything in the request header - works (I run the application through the RhoElements web server).

      However, when I have to pass certain parameters to the request header of the Web API call (RESTful service), the call fails.

      Here’s the sample of the code:


      var apiEndPoint = “<Web API End Point>”;

      $.ajax({

      url: apiEndPoint,

      dataType: 'json',

      success: function (data) {

      <some_code>;

      },

      error: function (xhr, ajaxOptions, thrownError) {

                     <some_code>;

                  },

      beforeSend: function (xhr) {

      xhr.setRequestHeader("clientID", "<clientid_value>");

      xhr.setRequestHeader("ResourceID", "<resourceid_value>");

      xhr.setRequestHeader("Token", "<token_value>”);

      }

       

      Naturaly, the code works in the browser on the desktop.

      Are there any additional settings that I have to check or set?

      Thanks,

      Yuriy