webMethods CloudStreams 10.4 | webMethods CloudStreams | Administering webMethods CloudStreams | Cloud Connections, Services, and Connector Listeners | REST Parameters | Parameter Types | FORM_ENCODED_PARAM
 
FORM_ENCODED_PARAM
FORM_ENCODED_PARAM allows you to send simple key value parameters embedded in the Request body for POST or PUT requests. This uses the default web form encoding, which is application/x-www-form-urlencoded.
You can define a parameter of type FORM_ENCODED_PARAM if you want to send the parameter as part of the Request body. You can also format the input data into a desired output format using the formatter, similar to QUERYSTRING_PARAM.
To define a form URL encoded parameter, you have to create a parameter type and set the style as FORM_ENCODED_PARAM
Example
A sample resource definition with FORM_ENCODED_PARAM parameter is as follows:
<resource method="POST" path="/Accounts" name="CreateSubAccount"
displayName="Create SubAccount">
<description>Create new subaccount</description>
<parameters>
<parameter name="FriendlyName" isRequired="true"
style="FORM_ENCODED_PARAM">
<description>Friendly Name</description>
</parameter>
<parameter name="Status" isRequired="true"
style="FORM_ENCODED_PARAM">
<description>Status of account</description>
</parameter>
</parameters>
<responses>
...
</responses>
</resource>
For passing parameters of FORM_ENCODED_PARAM type, you must not define the Request body for a Resource, as the generated parameter key value string will be automatically embedded in the Request body. In the above example, two parameters of type FORM_ENCODED_PARAM are defined as FriendlyName and Status. When the service created by the sample resource definition is run, the following sample Request payload is sent to the back end:
POST /2010-04-01/Accounts/AC53e967de85059b65475d0059882a9e02 HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 39
Host: api.twilio.com
Connection: Keep-Alive
Authorization: Basic ********************************
FriendlyName=NewFrName&Status=suspended is also sent as part of the same Request body:
FriendlyName=NewFrName&Status=suspended
In the above sample Request payload, as the Content-Type is automatically set to application/x-www-form-urlencoded, you do not have to explicitly set the Content-Type. Further, the parameters, FriendlyName and Status are URL encoded and are specified as an ampersand (&) separated list of key-value pairs (FriendlyName=NewFrName and Status=suspended), with the corresponding Content-Length set accordingly.

Copyright © 2013- 2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Innovation Release