json and files attributes of the requests module

You cannot have both files and data, so you’ll need to put one inside the other.

Putting binary files to JSON is inefficient and error-prone.

So you can put data inside files like this:

         'f': open('...'), 
         'data': json.dumps({...})  # move data here

At server side though you need to alter your code, in flask that would be

- request.json
+ json.load(request.files['data'])

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top