Step 3: Callout Template Request Body (Form-Encoded Format)
Request Body Page (Form Encoded Body Builder)
If you selected “Form Encoded” in the first step of the wizard for “Request Body Format”, the 3rd step will let you build the form encoded POST string.
The Form-Encoded body is composed of name-value pairs in the format name1=value1&name2=value2…
In order to define new body elements, click on the ‘Add’ icon. A new popup will be displayed, where you can add the details of the form element:
When adding a new node, first we need to set the Node Name, a name to define the value. You can type in a static node name (the most commonly used option) or dynamically define a node name by clicking the edit icon on the right side of the input. The edit button opens a popup with various options for dynamic node name generation, including using a field from the main object, a formula, a custom label, a custom metadata value, or a custom setting value.
If you select the Node Type as “Single Value“, you can specify what value to use in the “Value Source” input:
- Static value: You can set a static value to be sent to the server for the selected name. Simply select “Static” for Value Source, then add your static value below.
- Field: This option allows you to map a field from the selected main object or any related record. Select “Field” for Value Source. The Field Selector allows you to select fields from the Main Object, any related object and any related list. For example, if the Main Object is Account, the selection below allows you to select the Username of the Owner of the Account.
- Formula: This option allows you to build a formula using the current object’s fields that will be used to generate the node.
- Clicking the Edit icon will open the Formula editor. See more details in the “Using Formulas” section of this user guide.
- Custom Label: This option allows you to provide a custom label name to be mapped in that node.
- Custom Metadata: This allows you to map a field from a Custom Metadata Type record.
- Custom Setting: This allows you to map a field from a Hierarchy or List Custom Setting record
- Input parameter: This allows you to use an input parameter when the call is made from a flow. Learn more about input parameters.
- Build a JWT: This allows you to build a JWT token to be sent to the external system. Learn more about JWT nodes.
If you select the Node Type as “Built using an Apex Class“, you can generate the value of the node using an Apex class.
Create from sample body
If you have a body Sample from the API documentation from the app or platform being implemented, you can create your Request Body quickly by utilizing the ‘Generate from sample body’ button. This enables you to quickly map your Main Object to your external system bypassing creating Node Names with stand-in values.
Copy the sample Request Body and paste it into the text box.
Click “Generate and replace exiting body” and you will see this has been added into the Request Body of your Callout Template. From here, you can begin mapping Salesforce fields from your Main Object by selecting the edit icon next to the row and replacing the static values from the sample body. This helps you to quickly map without having to manually create each Node Name with a provided guide from your external system API documentation.
NOTE: If you have started mapping in the fields in the body and you opt to utilize the ‘Generate from sample body’ button, your previous mapping will be overwritten. It is advised you begin with your sample body first before mapping additional Nodes.