requests / toolbelt

A toolbelt of useful classes and functions to be used with python-requests
https://toolbelt.readthedocs.org
Other
996 stars 184 forks source link

How do I send this post request using requests_toolbelt #344

Closed bishopmarcel closed 1 year ago

bishopmarcel commented 1 year ago

data = {'person': [{'name': 'John', 'age': 30}, {'name': 'Jane', 'age': 25}]}

pquentin commented 1 year ago

You can just use regular requests which has a json parameter: https://requests.readthedocs.io/en/latest/user/quickstart/#more-complicated-post-requests. Closing as this is a question and not an issue. Please don't use the bug tracker for that.

bishopmarcel commented 1 year ago

What I want to express is whether the request can be supported in this way

data = {'person': [{'name': 'John', 'age': 30, 'avatar': ("John.jpg", open("John.jpg", "rb"), "image/jpeg")},
                   {'name': 'Jane', 'age': 25, 'avatar': ("Jane.jpg", open("Jane.jpg", "rb"), "image/jpeg")}]}
encoder = MultipartEncoder(fields=data)