The multipart format is a way of structuring data in an API request or response that allows files and different content data types to be transmitted together as a single unit.
In Astera API management for the consumption of APIs, the multipart format can be used to simplify the process of uploading or downloading files, or when sending a single request that contains both file data and metadata.
Now, you can consume APIs using an API Client that supports multipart content.
For our use case, we will be configuring an API Connection object and an API Client object. Within the API Client object, we will set multipart as the Input Content-Type, so that we can upload a file and text field to the server.
For our use case, we will be working with a pre-configured API Connection object.
The endpoint we intend to hit is the POST HTTP method which is going to allow us to upload files and text fields to the server. Our resource is going to be ‘files’ and we are going to keep our input content-type as Multipart.
It requires us to add a file path of the file we intend to upload and the text string of the text that is going to be uploaded.
Next, drag and drop an API Client object onto the same flow.
Configure the API Client object with the API Connection.
The HTTP Method will be Post, the Resource will be “files” as seen from the API endpoint above.
Select the Input Content Type as multipart/form-data.
Click Next until you reach the Input Layout screen.
Here, we will be adding a file that we wish to upload as well as a text string.
Note: This path can be parametrized and mapped from outside as well.
Click OK and run the dataflow.
As you can see in the Job Progress window, our file has been uploaded as part of API request and the text string has also been added to the request payload.
This concludes the document on making Multi-part (consumption) API calls.