--- title: "API Best Practices" slug: "api-best-practices" updated: 2026-01-06T01:22:30Z published: 2026-01-06T01:22:30Z canonical: "docs.preset.io/api-best-practices" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.preset.io/llms.txt > Use this file to discover all available pages before exploring further. # API Best Practices ## 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-Type` request 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-Type` header** - 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-Type` header includes a boundary - The `Content-Type` header is not manually overridden - Files are passed using the correct form field name (for example, `formData`) - Additional parameters (such as `passwords` or `overwrite`) are valid and correctly formatted