“Form Data” is a feature for sending complex data and files in REST applications. It is mainly used when there is a need to send multiple types of data (such as text, numbers and files) in a single request, facilitating integration with APIs that require data in specific formats.
To create a “Form Data”, follow these steps:
- Create a REST-type module.
- Then click on “New operation”. Fill in the “General information” and “Parameters”.
- The configuration step of the “Request” tab is crucial for Form Data. Click on the “Header” tab.
- Note that the platform automatically shows a value (application/json) for the “Context-Type” key. Change this value to multipart/form-data.
- Next, in the “Body” tab, the parameters must be sent as named fields with their respective values, which is different from the commonly adopted standard. This is essential so that the platform can read and interpret the data correctly.
The format to be used in the “Body” is:
key:value:type
As such:
- The type is optional;
- A line break must be added between each key;
- The type is a mime type (read more in the reading suggestions at the bottom of the page).
Body example
In a scenario where we normally send a JSON in the body of platform requests, we would have something like the example below:
{
"file": "base64",
"action": "save",
"user": "549875414515"
}