function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
we-mpwe-mp 

Salesforce Live Agent REST API - getting SessionId

Hello,  Using the below code (snippet posted), we are trying to get a SessionId
ajaxRequest.open("GET", "LiveAgentAPIEndpoint/chat/rest/System/SessionId"", true);
ajaxRequest.setRequestHeader("X-LIVEAGENT-AFFINITY",null);
ajaxRequest.setRequestHeader("X-LIVEAGENT-API-VERSION","30.0");
ajaxRequest.send(null);
This is returning a status of 400 - Any idea on what could be incorrect here? 

Thanks.

ShashForceShashForce
There is an extra quote character in your line 1.

Please try something like this:

ajaxRequest.open("GET", "https://LiveAgentAPIEndpoint/chat/rest/System/SessionId", true);
ajaxRequest.setRequestHeader("X-LIVEAGENT-AFFINITY",null);
ajaxRequest.setRequestHeader("X-LIVEAGENT-API-VERSION","30.0");
ajaxRequest.send(null);

If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.

Thanks,
Shashank
we-mpwe-mp
Thanks, Shashank.
That extra quote was a typo when posting the question - Any other thoughts?

zubalzubal
ajaxRequest.setRequestHeader("X-LIVEAGENT-API-VERSION","30");
if you change api version format than should be ok. I am getting status 200.