简体   繁体   中英

Python Requests Library not encoding dictionary payload properly for post request

So I'm working on a python script that uses the requests library to make a post request after gathering some data from some web API's.

At the end, I have a dictionary that looks something like

my_data = {"link": "value", "name": "value", "last_event": "value", people: []}

Whenever I run the following code to make a request:

post_r = requests.post("http://127.0.0.1:3000/companies", data=my_data)

I find that the server receives the value of data to only be equal to the string "last_event", ignoring everything else.

Does anybody have any idea why this would happen?

(If it matters, the server the code is hitting is a rails server).

解决了它-因为我使用的是嵌套字典,所以当我使用json=my_data时它可以工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM