Chat API endpoint /chat/rest/Chasitor/ChatMessage results in 500 error if called in quick succession
Trailblazer Community

Chat API endpoint /chat/rest/Chasitor/ChatMessage results in 500 error if called in quick succession

API , Mobile , Live Agent , Omni-Channel

Last updated 2021-10-12 ·Reference W-7325349 ·Reported By 5 users

No Fix

Summary
Chat API endpoint /chat/rest/Chasitor/ChatMessage results in Error 500: An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. Error ID: 1460560579-917 (-1292368750)

Repro
1) In a demo org, have chat enabled.
2) Make sure an agent is online.
3) Open a REST client (for our repro, we can use POSTMAN client)
4) For the first part, invoke the three API endpoint, as stated below, in a manual fashion, one by one.

/chat/rest/System/SessionId
/chat/rest/Chasitor/ChasitorInit
/chat/rest/Chasitor/ChatMessage

You will notice that all 3 work fine.

5) Now, in POSTMAN, chain these 3 requests together in a collection and run.
6) You will notice the ChatMessage call gives a 500 server error response.

Workaround
Calling an additional endpoint /chat/rest/System/Messages before the /chat/rest/Chasitor/ChatMessage endpoint makes the error go away. Refer to link below for using this endpoint along with the ack parameter set to –1.

https://developer.salesforce.com/docs/atlas.en-us.live_agent_rest.meta/live_agent_rest/live_agent_rest_Messages.htm

Updates
Please note that the behavior reported in this known issue is expected behavior.

Calling the /chat/rest/Chasitor/Messages and waiting for the ChatRequestSuccess response (see https://developer.salesforce.com/docs/atlas.en-us.live_agent_rest.meta/live_agent_rest/live_agent_rest_ChatRequestSuccess.htm) before the /chat/rest/Chasitor/ChatMessage endpoint makes the error go away. ChatRequestSuccess will only return once the transcript is ready. In reality though, ChatMessage should only be called after ChatEstablished is returned in the Messages poll, as that means an agent is connected to the chat.

Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.