Legacy Dev Forum Posts

 View Only

Sign Up

3rd Party Routing API - 400 Bad request returned

  • 1.  3rd Party Routing API - 400 Bad request returned

    Posted 06-05-2025 18:15

    Peter_Tailby | 2019-08-20 07:31:14 UTC | #1

    Hi team,

    I'm trying to call the 3rd Party Chat and Email routing API by sending a POST to /api/v2/conversations/emails however PureCloud returns 400 Bad request - Malformed Syntax.

    I've got this to work using POSTMAN - no problem there. I'm now trying to use a Lambda function to make this request but I get a 400 Bad request returned.

    I'm using the same Oauth method (Client credentials) and the same JSON body to create the email but it won't work.

    Could someone have a look and see what I'm doing wrong please?

    Request: requestHeaders = { "Content-Type": "application/json", "Authorization":"Bearer " +token } requestBody = { "flowId": "4249fb06-e770-48b4-9b43-e5040018f0c3", "provider": "Acme", "toAddress": "support@xxxxxx.com", "toName": "Customer Support Team", "fromAddress": "mickeymouse@gmail.com", "fromName": "George Customer", "textBody": "this is some text", "subject": "Support email" }

    create 3rd party email object

    r = requests.post("https://api.mypurecloud.ie/api/v2/conversations/emails", headers=requestHeaders, data=requestBody)

    Response {"status": 400, "code": "bad.request", "message": "The request could not be understood by the server due to malformed syntax.", "contextId": "3da7f0de-7881-4799-a12e-458b329a8846", "details": [], "errors": []}

    Many thanks,

    Peter


    Jason_Mathison | 2019-08-20 14:23:16 UTC | #2

    It looks like you might need to change data=requestBody to json=requestBody.

    https://stackoverflow.com/questions/15900338/python-request-post-with-param-data

    --Jason


    Peter_Tailby | 2019-08-20 15:40:29 UTC | #3

    Hi Jason,

    That fixed it. Many thanks for your help!

    Pete


    system | 2019-09-20 15:40:32 UTC | #4

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


    This post was migrated from the old Developer Forum.

    ref: 5821