Legacy Dev Forum Posts

 View Only

Sign Up

Application/x-www-form-urlencoded

  • 1.  Application/x-www-form-urlencoded

    Posted 06-05-2025 18:49

    agilio | 2019-11-06 20:41:12 UTC | #1

    When I test using Postman if I use the application/x-www-form-urlencoded header it the REST call I'm doing works. But when I try to do the same POST in purecloud we are getting "Message body is required." I have the Header of Content-Type application/x-www-form-urlencoded set on the data action in PureCloud. Anythoughts why this isn't working?


    Jason_Mathison | 2019-11-06 21:05:58 UTC | #2

    Could you upload an export of your action, with any sensitive bits redacted? A correlation ID from a failure would also be interesting to see.


    agilio | 2019-11-07 13:47:25 UTC | #3

    <a class="attachment" href="/forum/uploads/db6296/original/2X/5/5aebaea385f4fc77d8d3a31e94da1a056a3105b2.json">Post-OutboundSMS-2019110774504.custom.json</a> (1.6 KB)

    Here is an error example

    { "status": 400, "code": "bad.request", "message": "The request could not be understood by the server due to malformed syntax.", "messageParams": {}, "contextId": "41154fae-e7a4-4c22-8094-2f476f3c6465", "details": [ { "errorCode": "ACTION.REMOTEENDPOINT" } ], "errors": [ { "status": 400, "code": "BADREQUEST", "message": "REST call for action execute failed. Message:Request to backend service failed. Response from web service: &lt;?xml version='1.0' encoding='UTF-8'?&gt;\n&lt;TwilioResponse&gt;&lt;RestException&gt;&lt;Code&gt;21602&lt;/Code&gt;&lt;Message&gt;Message body is required.&lt;/Message&gt;&lt;MoreInfo&gt;https://www.twilio.com/docs/errors/21602&lt;/MoreInfo&gt;&lt;Status&gt;400&lt;/Status&gt;&lt;/RestException&gt;&lt;/TwilioResponse&gt; [41154fae-e7a4-4c22-8094-2f476f3c6465]", "messageParams": {}, "details": [], "errors": [] } ] }


    Jason_Mathison | 2019-11-07 15:01:12 UTC | #4

    The endpoint is expecting application/x-www-form-urlencoded, however you are passing in the raw input to your action, which is going to be JSON. Take a look at this thread for an example of how the request template should be formatted:

    https://developer.mypurecloud.com/forum/t/how-to-add-form-data-in-purecloud-action-request/5307


    agilio | 2019-11-07 22:08:03 UTC | #5

    I guess I'm not sure exactly which part of that you are referring too but it ends with

    "Content-Type": "application/x-www-form-urlencoded"

    Which I already have as a header. Did you look at the export I provided. If not hear is the configuration

    { "requestUrlTemplate": "https://api.twilio.com/2010-04-01/Accounts/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages", "requestType": "POST", "headers": { "Content-Type": "application/x-www-form-urlencoded", "Accept-Encoding": "gzip, deflate" }, "requestTemplate": "${input.rawRequest}" }

    Also it is showing here as well


    agilio | 2019-11-07 22:29:19 UTC | #6

    Hi I figured out what you were referring too in the other post.

    The request body needed the $esc.url() method to encode it.

    "To=$esc.url(\"${input.To}\")&From=$esc.url(\"${input.From}\")&Body=$esc.url(\"${input.Body}\")"

    One question does Genesys plan to accept responses in anything other than application/json? Or is there a way to hard code the response around that restriction?


    Jason_Mathison | 2019-11-08 14:24:57 UTC | #7

    Hi agilo,

    I'm glad you were able to figure out what I was talking about, sorry for not being more clear that it was the requestTemplate that needed to be changed.

    We are currently not working on support responses other than application/json, however please post what you are looking for to https://purecloud.ideas.aha.io/ideas/ for future consideration.

    --Jason


    system | 2019-12-09 14:24:58 UTC | #8

    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: 6429