- 06 Jan 2026
- 1 Minute to read
- Print
- DarkLight
API Best Practices
- Updated on 06 Jan 2026
- 1 Minute to read
- Print
- DarkLight
Multipart Boundary Handling for Import APIs
Preset and Superset import APIs (for example, dashboard, chart, and dataset imports) accept files using multipart/form-data requests. Correct handling of multipart boundaries is required for these endpoints to parse request payloads successfully.
This section explains how multipart boundaries work and provide guidance on how to avoid common request-formatting errors.
Why Multipart Boundaries Matter
When sending files using multipart/form-data, the HTTP request body is split into parts using a boundary string. This boundary must:
- Be present in the
Content-Typerequest header - Match the boundary used to encode the request body
If the boundary is missing or mismatched, the server cannot correctly parse the request. In this case, import APIs will fail with a generic error, such as:
{"message": "Arguments are not correct"}
Common Pitfall: Manually Setting Content-Type
A common cause of import failures is manually setting the Content-Type header to:
Content-Type: multipart/form-data
without including a boundary.
Many HTTP client libraries (including Python requests) automatically generate the correct Content-Type header with a boundary when a file upload is provided. If you override this header manually, the client library will not inject the boundary, resulting in an invalid request.
Recommended Approach
When calling Preset or Superset import APIs:
- Do not manually set the
Content-Typeheader - Allow your HTTP client to generate the header automatically
- Provide files using the client’s native multipart upload mechanism
Python (requests) Example
files = {"formData": open("dashboard.zip", "rb")}
payload = {"overwrite": True}
requests.post(
url,
headers={"Authorization": f"Bearer {token}"},
data=payload,
files=files,
)
In this example, requests automatically sets:
Content-Type: multipart/form-data; boundary=...
ensuring the request can be parsed correctly.
Affected APIs
This behavior applies to all Preset and Superset APIs that accept file uploads via multipart form data, including:
- Dashboard import
- Chart import
- Dataset import
- Database import (when applicable)
- Content migration endpoints
The same boundary-handling rules apply to all of these endpoints.
Troubleshooting Import Errors
If an import API returns:
{"message": "Arguments are not correct"}
verify the following:
- The request uses
multipart/form-data - The
Content-Typeheader includes a boundary - The
Content-Typeheader is not manually overridden - Files are passed using the correct form field name (for example,
formData) - Additional parameters (such as
passwordsoroverwrite) are valid and correctly formatted