3rd Party Routing API - 400 Bad request returned

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

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

--Jason

Hi Jason,

That fixed it.
Many thanks for your help!

Pete

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