+ Start a Discussion
MktdevMktdev 

Live Agent REST API Call Not working

I am trying to make connection with Live Agent Rest API but some how my headers are not getting set.

In the browser console I see the request is going out but when I try to see the request header its missing these two headers instead I only see these under Access-Control-Request-Headers:x-liveagent-affinity, x-liveagent-api-version

Error: Status Code: 400 Bad Request

Any thought?
$.ajax({
     url:"https://zzzzzzz.salesforceliveagent.com/chat/rest/System/SessionId",
     dataType: 'json', 
     Accept : "text/plain; charset=utf-8",
     type: 'GET',
     contentType: 'application/x-www-form-urlencoded',
      headers: {
      'X-LIVEAGENT-API-VERSION': '30',
      'X-LIVEAGENT-AFFINITY': 'null'
     },
     success:function(json){

         alert("Success");
     },
     error:function(textStatus ){
         console.log(textStatus );
         alert("Error"+textStatus );
     }      
});

 
ShashankShashank (Salesforce Developers) 
It's probably got to do with how the headers are set in JQuery. Please see if this helps: http://www.oyecode.com/2014/02/how-to-salesforce-rest-api-from-browser.html
rourou512rourou512
Hi Mktdev, 
Have you ever fixed this issue? I am meeting the same problem and cannot figure out how to solve. If you've already found the solution, would you please post it.
Thanks