Communication Channels

Get Involved. Join the Conversation.

Topic

    SJ
    Error while trying to access the Chat REST APIAnswered
    Topic posted February 13, 2019 by SJ Bronze Medal: 1,250+ Points, tagged Chat 
    228 Views, 4 Comments
    Title:
    Error while trying to access the Chat REST API
    Summary:
    OSC-CREST-00006 while trying to access establishSessions
    Content:

    Hello,

    I am trying to create a Chat REST Client based on the documentation .However, I am getting a 400 Bad Request Error.

    Here is my request {slightly modified from the example}

    POST /services/rest/crossChannelServices/latest/establishSessions HTTP/1.1

    {
     "sessionInformation": {
     "emailAddress" : "john.smith@vision.com",
     "firstName": "John",
     "lastName": "Smith",
     "question": "Blah",
     "auxiliaryData": { "BROWSER" : "Firefox" }
     }
    }

    Here is the response :-

    {
        "type": "https://<sitename>.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://<sitename>.custhelp.com/services/rest/crossChannelServices/latest/establishSessions",
        "o:errorCode": "OSC-CREST-00006"
    }

    I have tried this across multiple 18D sites. 

    Do I need to enable any specific (or hidden) configuration settings to access Chat REST API? 

    Thanks,

    Version:
    18D

    Best Comment

    Jessica Bradley

    Hi SJ,

    Here is some helpful information: There are a couple of issues with the syntax in the request below...

    First, the value associated with the sessionInformation field name needs to be wrapped in quotes as well, because sessionInformation has a field type of string (it is not an object or sub-object), like this:

    {

    "sessionInformation": "{<stuff>}"

    }

    After doing that you would then get a json parse error, because the data also needs to have the quotes within the string escaped - otherwise it thinks it has reached the end of the string and is confused, like this:

    {

    "sessionInformation": "{\"emailAddress\" : \"john.smith@vision.com\", \"firstName\": \"John\", \"lastName\": \"Smith\", \"question\": \"Blah\", \"auxiliaryData\": { \"BROWSER\" : \"Firefox\" } }"

    }

    In the postman utility I use, the json parser also complained about having newlines in the string, but I don’t know if not having newlines is an overall requirement or specific to postman for some reason.

    Hope this helps!

    --Jessica

    Comment

     

    • Michael Castafaro

      Hi

       

      Was wondering if you managed to solve this issue?

      I am having a similar problem expect I am getting the error "Unrecognized resource: crossChannelServices"

       

      Kind Regards

      Michael

    • SJ

      @Michael, No luck yet. I am guessing it to be a configuration issue and hoping someone in the forum will point me in the right direction :)

      I have not seen the error you specified. Are you on Version 18D? 

       

    • Jessica Bradley

      Hi SJ,

      Here is some helpful information: There are a couple of issues with the syntax in the request below...

      First, the value associated with the sessionInformation field name needs to be wrapped in quotes as well, because sessionInformation has a field type of string (it is not an object or sub-object), like this:

      {

      "sessionInformation": "{<stuff>}"

      }

      After doing that you would then get a json parse error, because the data also needs to have the quotes within the string escaped - otherwise it thinks it has reached the end of the string and is confused, like this:

      {

      "sessionInformation": "{\"emailAddress\" : \"john.smith@vision.com\", \"firstName\": \"John\", \"lastName\": \"Smith\", \"question\": \"Blah\", \"auxiliaryData\": { \"BROWSER\" : \"Firefox\" } }"

      }

      In the postman utility I use, the json parser also complained about having newlines in the string, but I don’t know if not having newlines is an overall requirement or specific to postman for some reason.

      Hope this helps!

      --Jessica

      • SJ

        Thanks Jessica. I did not realize that it is passed as a string. Thank you.

        I am guessing that since the value is read as string, having newlines or tabs in the code is throwing the parser on the server off.

        Thanks,

        SJ