• Sean Xiao
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I'm trying to using the Salesforcde Live Agent REST API from a webpage using angular and ajax requests.
When I first try to obtain the SessionId, performing an ajax request to <server>/chat/rest/System/SessionId, the browser first submits an OPTIONS preflight request.

Salesforce returns a 400 error response because the request doesn't include the headers X-LIVEAGENT-API-VERSION nor X-LIVEAGENT-AFFINITY. To verify if that was really the problem, I tried to add those headers and submit the request again using Postman. That time I got an 405 method not allowed error. That means that Salesforce can't service an OPTIONS request for that endpoint.

For what it looks like, Salesforce Live Agent doesn't support CORS. Is that correct? I would like to access the API directly from the client, without having to submit a request to my server and then a request to Salesforce Live Agent Api. Is this possible? Is there some way to have the Live Agent REST API servicing Ajax requests?