Send documents
You may need to attach documents to certain Dashdoc resources, such as:
Transport orders (e.g. weight notes, transport documents)
Invoices (e.g. proof of delivery)
Site entities (e.g. security protocols, instructions)
To support this, the Dashdoc API allows file uploads using multipart/form-data requests.
Requirements
When uploading documents, make sure to:
Use the HTTP header:
Content-Type: multipart/form-dataLet your HTTP client automatically generate the
boundaryparameter, which is required by the multipart encoding.
Example of the generated header:
Content-Type: multipart/form-data; boundary=Boundary_42_15460972_1713531308867The boundary is a unique string used to separate parts in the request body. It must match what's used in the actual body content.
Examples
Example: Using curl
curl -X POST https://www.dashdoc.com/api/v4/documents/ \
-H "Authorization: Token your_api_token" \
-F "file=@weight_note.pdf" \
-F "type=Documents" \
-F "transport=1f527452-45f4-11eb-a722-0242ac140004"
-F automatically handles the Content-Type and boundary.
Example: Using Python (requests)
import requests
url = "https://www.dashdoc.com/api/v4/transport-messages/"
headers = {
"Authorization": "Token your_api_token"
}
files = {
"file": ("weight_note.pdf", open("weight_note.pdf", "rb")),
}
data = {
"type": "documents",
"transport": "1f527452-45f4-11eb-a722-0242ac140004"
}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.status_code, response.json())Example: Using Postman
In Postman, when you select "form-data" as the body type and add your file and fields, Postman will automatically set the correct Content-Type: multipart/form-data header. It also handles the boundary parameter internally — this value is generated dynamically when the request is sent and does not need to be set manually.
Common Errors & Troubleshooting
Error:
{"detail":"Multipart form parse error - Invalid boundary in multipart: None"}Cause: The boundary is missing from the Content-Type header or does not match the request body.
Fix:
Don't set the
Content-Typeheader manually. Let your HTTP client or library handle it.If you're generating the request manually, make sure:
A unique boundary is defined.
It appears both in the
Content-Typeheader and correctly wraps parts in the body.
Error: 400 Bad Request
400 Bad RequestCause:
Required fields like
typeortransportare missing.The file is missing or empty.
Invalid values (e.g., unsupported type).
Fix:
Double-check field names and values.
Ensure the
typefield is one of the expected values ("note","load_verification","share","document"or"photo").Ensure
transportis a valid transport UID from your Dashdoc environment.
Best Practices
Test your request using Postman to inspect headers and payloads.
Let your HTTP client manage the
Content-Typeand boundary.Validate required fields early in your application to avoid request failures.
Last updated
Was this helpful?