Ensuring that your API reliably transfers data is a crucial component of quality. In mabl, you can create API tests that upload files with "formdata" and "binary" request types.
- Formdata request types can upload a file field plus other text fields.
- Binary request types upload a single raw file as the entire request body.
Upon saving the test, any new files are uploaded to mabl cloud for test execution. You can manage file uploads from your mabl workspace: Configuration > File uploads. By default, file uploads are supported up to 100 MB. The maximum filename limit is 255 ASCII characters. However, if the filename includes non-ASCII characters the limit may be as low as 84 characters, depending on character encoding and the 255 bytes available for filenames.
This article explains how to upload files in formdata and binary request types.
API tests only
While browser and mobile tests support file upload interactions in the UI, only API tests support formdata and binary file uploads. API steps in UI tests do not support formdata and binary request types.
As a workaround, you can add a separate API test and browser test to a plan and use shared variables.
File uploads in formdata requests
To upload a file within a formdata request type, take the following steps:
- Click on "formdata" in the Body tab. mabl sets
Content-Type: multipart/form-dataautomatically. - Select "File" from the Type dropdown.
- Upload a local file or choose an existing file from your mabl workspace.
Uploading a file in a formdata request body
File uploads in binary requests
To upload a file within a binary request type, take the following steps:
- Select "binary" in the Body tab.
- Upload a local file or choose an existing file from your mabl workspace.
Uploading a file in a binary request body
Note
The file is chosen from your workspace file uploads when you create or edit the test and cannot currently be set dynamically from a variable or DataTable.