MakotoNagai | 2019-11-29 04:48:47 UTC | #1
Hi,
I want to launch the SMS provider (Twilio) message sending API from the Custom Action of PureCloud.
I am referring to the following URL, but I have not been able to achieve it. (https://help.mypurecloud.com/articles/request-configuration-data-actions/)
Test results in Data Action settings
8. Execute: The request could not be understood by the server due to malformed syntax.
- REST call for action execute failed. Message:Request to backend service failed. Response from web service: {"code": 21602, "message": "Message body is required.", "more_info": "https://www.twilio.com/docs/errors/21602", "status": 400} [09be1705-a6c6-4f05-a9bc-fbc39f6ed7e1]
My settings are as follows. //// Contract input { "title": "Send SMS by Twilio", "description": "Information of Sending SMS", "type": "object", "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "To": { "description": "sendTo", "default": "+818020029999", "type": "string" }, "From": { "description": "sendFrom", "default": "+14049059999", "type": "string" }, "Body": { "description": "messageBody", "default": "SMS send test", "type": "string" } }, "additionalProperties": true }
//// Contract output { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Status Response", "description": "Returns Response-Code.", "type": "object", "properties": { "rawNumber": { "type": "string" } }, "additionalProperties": true }
//// Request configuration { "requestUrlTemplate": "https://api.twilio.com/2010-04-01/Accounts/ACd2856485836673b51ae1320039999999/Messages.json", "requestType": "POST", "headers": { "Content-Type": "application/json", "UserAgent": "PureCloudIntegrations/1.0" }, "requestTemplate": "{\"To\": \"${input.To}\",\"From\": \"${input.From}\",\"Body\": \"${input.Body}\"}" }
//// Response configuration { "translationMap": {}, "translationMapDefaults": {}, "successTemplate": "${rawResult}" }
The API specifications you want to use are as follows. Required parameters are 'To', 'From', 'Body'. https://www.twilio.com/docs/sms/send-messages
I don't know the reason for the error "Message body is required." Can anyone give me your follow opinion?
Regards,
Jason_Mathison | 2019-12-02 13:12:18 UTC | #2
Hi MakotoNagai,
Ironically I had a question about this same API from coworker less than a week ago, so I have a working reference to answer this question with!
This API expects a URL encoded body (not JSON), so you will need to make these changes to your request configuration:
"headers": { "Content-Type": "application/x-www-form-urlencoded" }, "requestTemplate": "body=$esc.url(\"${input.Body}\")&to=$esc.url(\"${input.To}\")&from=$esc.url(\"${input.From}\")"
In the future please export your action from the UI and post the resulting .json file in your forum questions, that makes it very easy to import your action into a test org.
--Jason
MakotoNagai | 2019-12-04 02:04:07 UTC | #3
Hi Jason,
It was very helpful! By setting it according to your reply, the problem has been cleared!
Regards,
system | 2020-01-04 02:04:10 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: 6605