Open Messaging API failing for special characters

Hi All,

I'm calling Genesys Cloud Open Messaging API (https://api.cac1.pure.cloud/api/v2/conversations/messages/inbound/open) from a Lambda function (NodeJs - request) and it works fine with normal characters in the text field e.g. "Hello world"; however, the API returns status code 400 with null in the error details when I send special characters in the text field and so the message is not delivered in Genesys Cloud.

For example, when I send the French word garçon, the API fails with 400 status code.

Here is a sample request with some redactions:

{
    "port": "443",
    "uri": "https://api.cac1.pure.cloud/api/v2/conversations/messages/inbound/open",
    "method": "POST",
    "headers": {
        "Content-Type": "application/json",
        "Content-Length": 425,
        "Authorization": "bearer {removed on purpose}"
    },
    "body": "{\"id\":\"54890901-dddd-4111-bbdb-01c15a121212\",\"channel\":{\"platform\":\"Open\",\"type\":\"Private\",\"messageId\":\"94e1e44e-b61f-4a16-bf70-11111111111\",\"to\":{\"id\":\"11120dba-9724-4a32-8ef2-121212121212\"},\"from\":{\"nickname\":\"1212121212\",\"id\":\"1212121212\",\"idType\":\"Phone\",\"firstName\":\"1212121212\",\"lastName\":\"\"},\"metadata\":{\"customAttributes\":{}},\"time\":\"2023-10-19T07:58:24.780Z\"},\"type\":\"Text\",\"text\":\"garçon\",\"direction\":\"Inbound\"}"
}

Strange enough when I use Postman, then the Genesys Cloud Open Messaging API works fine with special characters.

Any thoughts?

Thanks,
KNA

Is there anyone from Genesys who can help here?

Thanks,
KNA

@KNA it would be best to open a case with Care here Genesys Cloud Customer Care - Genesys Cloud Resource Center to see if they can help provide you with assistance. As it stands now, there isn't anything I can really gather from the information you provided to help you. Seems related to your application side at this point.

Hi @Greg_Boston, I have already opened a support case but they said they are not seeing any requests in the GC backend logs when the API in invoked from Lambda with special characters, and hence I'm posting here to seek help.

I don't see any other failures in Lambda logs (CloudWatch) other than when I invoke the Open Messaging API with special characters, where I get 400 in response. Is this something related to text encoding in unicode or similar issue? Does Open Messaging API has any such requirement?

As mentioned, the API call works totally fine when using normal characters, so apparently the API request code is ok.

Any thoughts on that will be appreciated.

Regards,
KNA

Are you getting a ININ-Correlation-Id in the header response from Genesys Cloud when you invoke the POST open messaging request? Care should be able to use that to help you here if so. Also what is the full response body you receive on the 400 response?

Thanks, @Greg_Boston. Please see below:

toJSON: [Function: responseToJSON],
caseless: Caseless {
dict: {
'content-type': 'application/json',
'content-length': '198',
connection: 'close',
date: 'Thu, 19 Oct 2023 20:52:24 GMT',
'inin-correlation-id': '1a78b7c3-7cc0-404b-833a-3e3935d79666',
'strict-transport-security': 'max-age=600; includeSubDomains',
'cache-control': 'no-cache, no-store, must-revalidate',
'x-cache': 'Error from cloudfront',
via: '1.1 05cf67c96e96cd376921ba5b65795a56.cloudfront.net (CloudFront)',
'x-amz-cf-pop': 'HIO52-P2',
'x-amz-cf-id': 'bE8XJK5LNFf6LUDEfJ_OWoyg2FrSaVFC-TUb-CxrlfKzrIfqB5u8LA=='
}
},
body: '{"message":"The request could not be understood by the server due to malformed syntax.","code":"bad.request","status":400,"contextId":"1a78b7c3-7cc0-404b-833a-3e3935d79666","details":[],"errors":[]}'

I'll send them the inin-Correlation-Id, but how do you read the above error?

It appears to be coming from Genesys, right?

Thanks,
KNA

Correct. It's an error coming from Genesys there. Care should be able to take that correlationId and help you out. It could be any number of things. The only troubleshooting I would suggest is to output to the console or logs, your request body and headers, that you are passing in the POST request in Postman and your NodeJs app and then compare them. Is there anything that looks different between the working and failing examples?

Thanks, @Greg_Boston. Yes, I did compare and sent the same to Care and they didn't find any difference either from the looks of it. I have now sent further details to Care and will wait to see their response.

Your tip to check inin-Correlation-Id did help to push the investigation further, so I appreciate your help!

I'll post here again should I need further help on this issue.

Thanks,
KNA

Hi @Greg_Boston

So, after I shared inin-correlation id with Genesys Support, the found the below exception occurring on their end:

"Error code [bad.request] type [JsonParseException] message [Illegal character ((CTRL-CHAR, code 0)): only regular white space (\r, \n, \t) is allowed between tokens] cause type [] cause message []",

And they commented as:

"This seems to point to the JSON request made by the application containing Illegal characters when a special character is sent from your application"

But they said, they cannot provide any further context other then that Genesys is receiving illegal NULL JSON characters in the requests from my application containing the special characters, causing the bad request.

Based on the above info, are you please able to share any further thoughts or where to from here?

Appreciate your help.

Regards,
KNA

Hmm, seems encoding related. Which you eluded to early on, in a previous post. There is some decent information in this stackoverflow page around similar errors - java - Jackson error "Illegal character... only regular white space allowed" when parsing JSON - Stack Overflow
Maybe something there can help you out?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.