How to use Form Data
Last updated
Last updated
“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:
As such:
key: name of the Form Data key.
value: value in text or base64.
type (optional): value type (mime type). Read more in the suggested reading section at the end of the page.
filename (optional): file name, applicable when the value is in base64. APIs that receive this data use the filename to generate the corresponding file.
If you choose to use the filename, you must include the type.
In a scenario where we normally send a JSON in the body of platform requests, we would have something like the example below:
As I said before, the body in the data form works in a different way where following the steps of the assembly rule we would have something like this:
The platform does not process files directly. Any file sent will be in base64. This string will then be processed by the platform, making it easier to send files such as images and documents.
Finish the module creation steps.
Done! You can now use this module in your integration flow.