#Send checkbox using multipart/form-data

7 messages · Page 1 of 1 (latest)

snow pewter
#

I'm trying to create a new document using the REST API. This document includes a file upload, but it also has a checkbox field. This looks to be impossible to accomplish, because there is no way to send a boolean using multipart/form-data, thus the checkbox validation will always fail.
Am I missing something?

wheat craterBOT
snow pewter
#

I just looked into how the Admin does this and it just sends anything but the file as a JSON string inside the _payload field. Is this a documented feature?

graceful abyss
#

Hey @snow pewter!

#

Did you find a solution to your problem?

I try this but it doesn't work:

  response = requests.post(
        url,
        headers={"Authorization": f"users API-Key {payload_api_key}"},
        files={"file": (filename, image_content, "image/jpeg")},
        json={"_payload": {"productIdAlpha": product_id_alpha}},
    )
#

Ah it's:

#
        url,
        headers={"Authorization": f"users API-Key {payload_api_key}"},
        files={
            "file": (filename, image_content, "image/jpeg"),
            "productIdAlpha": (None, product_id_alpha),
        },
    )