0

I have Customized chat window and I need to connect with salesforce live agent so I integrated LiveAgent API of salesforce. For closing the chat I trigger end chat API I am getting 200 response but chat window is not closing.

endChat(userId: string){

        let objArr: User[] = JSON.parse(localStorage.getItem('userCreden'));
        let len = objArr.length;
        let user: User;
        for (let i = 0; i < len; i++) {
            if (userId == objArr[i].userId) {
                user = objArr[i];
                break;
            }
        }

        let sessionIdRespParsed = user.sessresp;

        let live_agent_url = this.appConfig.getConfig().live_agent_server_url;
        this.httpClient.post<HttpResponse<string>>(live_agent_url + '/chat/rest/Chasitor/ChatEnd', {
            "reason":"client"
        }, {
                headers: new HttpHeaders({
                    'X-LIVEAGENT-API-VERSION': '34',
                    'X-LIVEAGENT-AFFINITY': sessionIdRespParsed.affinityToken,
                    'X-LIVEAGENT-SESSION-KEY': sessionIdRespParsed.key,
                    'X-LIVEAGENT-SEQUENCE': '1'
                })
        }).subscribe(
            res => {
                console.log("response of Chat end  " + res);
            },
            err => {

            }
        );
    }
2
  • 1
    Welcome to sfse, please take some time to read How to Ask and take the tour. Once you have done so, make sure you include the relevant code (preferable, minimal reproducible code sample) and a clear description of the problem alongside any errors.
    – Eduard
    Commented Jul 19, 2018 at 9:30
  • @Eduard i am new to StackExchange next time i will take care. :). You have solution of my error i am getting 200 response code but still chat is not closing. Commented Jul 19, 2018 at 9:54

1 Answer 1

0

I don't know if this is still relevant to you. But I had the same issue and it seems like simply deleting this header:

'X-LIVEAGENT-SEQUENCE': '1'

does the trick.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .