When you specify your body to a JSON string, you can no longer attach a file since file uploading requires the MIME type multipart/form-data
.
You have two options:
- Encapsulate your JSON string as part as the form data (something like
json => json.dumps(data)
) - Encode your file in Base64 and transmit it in the JSON request body. This looks like a lot of work though.