Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass null as a value in a POST request on python?

I'm trying to send a POST request with params that contain null values and None just gets ignored. Besides that, I'm unsure about whether or not False is sent as false.

For example:

requests.post("http://myurl.com/address/", data = {"parentValue":{"value1":False,"value2":None}})

and the required params server-side are

{"parentValue":{"value1":false, "value2":null}}

tl;dr: I need false and null on the server side as params from a POST request, how do I send them using Python requests?

like image 769
Ignacio Mora Avatar asked Mar 17 '26 21:03

Ignacio Mora


1 Answers

As roganjosh suggested, json.dumps() on the object needed, works.

like image 122
Ignacio Mora Avatar answered Mar 20 '26 10:03

Ignacio Mora



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!