Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  Malformed Syntax

    Posted 06-05-2025 18:32

    alex7 | 2024-10-31 17:17:08 UTC | #1

    I've been trying to get the open messages API to work, but I keep getting a malformed syntax. To make sure I'm not doing something wrong in the code, I tried just using the API Explorer's cURL command and I get the same result. The verbose output shows the following (edited out token and integration id):

    POST /api/v2/conversations/messages/[integration id]/inbound/open/message HTTP/1.1 Host: api.mypurecloud.com User-Agent: curl/8.8.0 Accept: / Authorization: Bearer [token] Content-Type: application/json Content-Length: 245

    • upload completely sent off: 245 bytes
    • schannel: remote party requests renegotiation
    • schannel: renegotiating SSL/TLS connection
    • schannel: SSL/TLS connection renegotiated

    < HTTP/1.1 400 Bad Request < Content-Type: application/json < Content-Length: 198 < Connection: keep-alive < Date: Thu, 31 Oct 2024 17:06:42 GMT < Cache-Control: no-cache, no-store, must-revalidate < ININ-Correlation-Id: ae896191-b9cf-4c7b-8bee-bada4894b8d0 < Strict-Transport-Security: max-age=31536000; includeSubDomains < X-Cache: Error from cloudfront < Via: 1.1 6c1e463b1907685097cce9e63f1cf75a.cloudfront.net (CloudFront) < X-Amz-Cf-Pop: JFK52-P1 < X-Amz-Cf-Id: wEtl2efOVOXBf30y_XTtMSWdJeDgCUlYcREpq8oE1VAP1kOUTgoDFQ== < {"message":"The request could not be understood by the server due to malformed syntax.","code":"bad.request","status":400,"contextId":"ae896191-b9cf-4c7b-8bee-bada4894b8d0","details":[],"errors":[]}* Connection #0 to host api.mypurecloud.com left intact

    Any idea what could be wrong?

    Here is the curl command:

    curl -X POST "https://api.mypurecloud.com/api/v2/conversations/messages/[integraiton id]/inbound/open/message" -v -H "Authorization: Bearer [token]" -H "Content-Type: application/json" --data-raw $'{\"channel\":{\"from\":{\"nickname\":\"Nickname\",\"id\":\"nick@name\",\"idType\":\"Email\",\"firstName\":\"Nick\",\"lastName\":\"Name\",\"email\":\"nick@name\"},\"time\":\"2024-10-30T18:35:53.387Z\",\"messageId\":\"messageidnot_required\"},\"metadata\":{\"BusinessUnit\":\"BCC\"}}}'


    tim.smith | 2024-10-31 17:30:05 UTC | #2

    There's an extra curly brace at the end.


    Greg_Boston | 2024-10-31 17:30:35 UTC | #3

    Your body looks to have an extra } at the end. Doesn't look like proper JSON to me. that could be the reason


    alex7 | 2024-10-31 17:56:36 UTC | #4

    Here I was double-checking, triple-checking, making sure it wasn't something trivial before I post.

    Thank you. Not sure why my curl statement showed up like that, but in my code, json.dumps seems to be adding an extra } for some reason. But that's out of scope here.


    system | 2024-11-30 17:57:20 UTC | #5

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


    This post was migrated from the old Developer Forum.

    ref: 30151