I'm trying to make a simple REST GET request to salesforce Live Agent API to check whether service is available.
I can make the simple GET request successfully from my Web based REST client (Chrome Plugin - Boomerang) but am unable to successfully make the request from JQuery $.ajax.
I am getting a 400 Bad Request error.
$(document).ready(function(){
checkAvailable("https://d.xxx-xx-xxx.salesforceliveagent.com/chat/rest/Visitor/Availability?org_id=xxxxxxxxxxxxxxx&deployment_id=xxxxxxxxxxxxxxx&Availability.ids=[xxxxxxxxxxxxxx]");
});
function checkAvailable(URL)
{
$.ajax({
url: URL,
type: "GET",
beforeSend: function(xhr){
xhr.setRequestHeader('X-LIVEAGENT-AFFINITY', "null");
xhr.setRequestHeader('X-LIVEAGENT-API-VERSION', "41");
},
success: function(response) { alert('Success: ' + response); },
error: function(req, err){ console.log('Error Message: ' + err); }
});
}
Can anyone shed some light on what I might be doing wrong ? I suspect the issue is with the data format but my Rest client has no issues with it.