Post request to artifacts/generate returns no multipart boundary param in Content-Type'

Hi All,

I’ve been trying to upload a file using the /api/management/v1/deployments/artifacts/generate endpoint, however it returns the following error:

{'error': 'no multipart boundary param in Content-Type', 'request_id': 'd915bbaf-78bc-4a08-a9de-a7752a3f4309'}

when running the following python code using requests and I’m not sure what could be causing it. Any suggestions or ideas would be appreciated. Thanks

        self.post_headers = {
            'Content-Type': 'multipart/form-data',
            'Accept': 'application/json',
            'Authorization': self.authorization

        with open("/home/user/workspace/deploy/deploy/demo.txt", "rb") as f:
            deb_file =


        payload = {
            'name': "test",
            'description': "test",
            'device_types_compatible': ["test"],
            'type': "single_file",
            'args': "string",
            'file': deb_file

        r ='',
                          data=payload, headers=self.post_headers)

Hi @sowmr,

Thanks for reaching out. Just guessing (and googling): have you tried this? Error when POST file multipart/form-data · Issue #505 · github/fetch · GitHub


Had the same problem. Do NOT define the Content-Type in your header.

Requests will handle this for you. Simply define your file in files (Docs: Quickstart — Requests 2.31.0 documentation)

# # Mender API endpoint for generating artifacts
    mender_api_url = ""

    headers = {
        "Authorization": f'Bearer {token.decode()}'

    # Read the content of the certificate file
    with open('testcert.pem', 'r') as cert_file:
        certificate_content =

    # Convert the content to raw bytes
    certificate_bytes = certificate_content.encode('utf-8')

    # Define the artifact data
    data = {
        "name": "TEST",
        "description": "Test artifact generated via REST API - 01",
        "device_types_compatible": ["raspberrypi4"],
        "type": "single-file"

    # Send the POST request to generate the artifact
    response =, headers=headers, data=data, files={'file': ('my_cert.pem', certificate_bytes)})


1 Like

Guess we can mark the post by @fhkatcsw as solution. Thoughts @sowmr?


This should also be included in the REST docs.

The proposed solution is the one @sowmr ran into.