Uploading Files (multipart/form-data)
Some APIs require you to upload files, which is usually done using the multipart/form-data content type.
This can be achieved in Midio using Http.Body.Create Form Field File Http.Body.Create Form Field Value and Http.Body.Encode Multipart FormData .

In the example above, we fetch an image as a buffer, which we then convert to a form field file using Create Form Field File. All form fields are sent as inputs to Encode Multipart FormData, which returns two values: a Content-Type header value and the encoded body. We place the header value in an object with the field value Content-Type and use it in the headers input when calling the API that requires a file upload. We use the multipart/form-data output as the body.
It is important to include the header, as it contains information about how the form data is encoded in the body.
Last updated