Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Vijay Krishna
    Chat REST ServiceAnswered
    Topic posted October 16, 2019 by Vijay KrishnaBlue Ribbon: 750+ Points, tagged REST 
    26 Views, 2 Comments
    Title:
    Chat REST Service
    Summary:
    Issue with establish session - Chat REST API
    Content:

    Hi,

    I'm trying to invoke Chat REST services for a custom integration. But I am getting an error while calling establish session REST API. Please find the details below. .

    API: https://xxxxx.custhelp.com/services/rest/crossChannelServices/latest/establishSessions

    Body

    {
     "sessionInformation": {
     "emailAddress" : "vijay.krishna@speridian.com", 
     "firstName" : "Vijay",
     "lastName": "Krishna", 
     "question" : "Test Chat",
     "auxiliaryData" : {
    "BROWSER" : "Mobile Safari 11.0", 
    "OPERATING_SYSTEM" : "iPhone OS", 
    "USER_AGENT" : "Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1"

      }
     }
     
    Response
    {
    "type": "https://xxxxx.custhelp.com/services/rest/crossChannelServices/exceptions/OSC-CREST-00006",
    "title": "An attempt to write a resource failed",
    "status": 400,
    "detail": "A problem setting a property was encountered: not an object; EstablishSession.SessionInformation",
    "instance": "https://xxxxx.custhelp.com/services/rest/crossChannelServices/latest/establishSessions",
    "o:errorCode": "OSC-CREST-00006"
    }

     

     Please suggest if any parameter is missing.

    Thanks,

    Vijay Krishna

    Version:
    19B

    Best Comment

    Robert Surujbhan

    Vijay, try the attached body payload instead.  With the /establishSessions API endpoint, the value of the sessionInformation key itself has to be an escaped JSON string.

    {
        "sessionInformation": "{\"emailAddress\":\"vijay.krishna@speridian.com\", \"firstName\":\"Vijay\", \"lastName\":\"Krishna\", \"question\":\"Test Chat\", \"auxiliaryData\": {\"BROWSER\":\"Firefox\", \"OPERATING_SYSTEM\":\"iPhone OS\", \"USER_AGENT\":\"Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1\"}}"
    }
    

    Comment

     

    • Robert Surujbhan

      Vijay, try the attached body payload instead.  With the /establishSessions API endpoint, the value of the sessionInformation key itself has to be an escaped JSON string.

      {
          "sessionInformation": "{\"emailAddress\":\"vijay.krishna@speridian.com\", \"firstName\":\"Vijay\", \"lastName\":\"Krishna\", \"question\":\"Test Chat\", \"auxiliaryData\": {\"BROWSER\":\"Firefox\", \"OPERATING_SYSTEM\":\"iPhone OS\", \"USER_AGENT\":\"Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1\"}}"
      }
      
    • Vijay Krishna

      Thanks Robert Surujbhan.  It worked when I passed escaped JSON string.