Q:

Make HTTP request without double quotes in json

I want to make a POST HTTP request using requests library by including json parameters as follows:
r = requests.post(url, json={"field1":"value1", "field2":"null", verify=False)

Field2 value must be null and the server expects null without double quotes "null".
I have also tried to assign null to a variable:
variable = "null"
r = requests.post(url, json={"field1":"value1", "field2":variable, verify=False)

But the request is made by including double quotes. How can I make the request to have the json value of field2 being only null without quotes?
Thanks.

A:

First of all, your code lacks closing bracket } before verify=False:
r = requests.post(url, json={"field1":"value1", "field2":"null"}, verify=False)
#                                                              ^

If you want to set JSON field to null, set its python equivalent to None:
import requests

r = requests.post(url, json={"field1": "value1", "field2": None}, verify=False)
#                                                            ^

