As @lepsch has mentioned, the requests
library will not add None
values to your query parameters. However, I feel like there is a misunderstanding in the entire question.
The URL https:/api.server.com/v1/users/?parent=null
does not have the query parameter set to None
. It is in fact set to 'null'
, which is actually a string with the data "null" inside of it. Therefore, if you want to do this, all you have to do is change None
in your request to 'null'
:
requests.get(
BASE_URL + USER_URL,
headers = get_headers(),
timeout = 60,
params = {
'parent': 'null'
}
)
# This will request
# https:/api.server.com/v1/users/?parent=null
However, if you want a true null value, then you should consider either putting an empty string value... :
...
params = {
'parent': ''
}
...
# This will request
# https:/api.server.com/v1/users/?parent=
... or use the actual null encoded character, as described in this answer:
requests.get(
BASE_URL + USER_URL + "?parent=%00", # Must be added directly, as to not encode the null value
headers = get_headers(),
timeout = 60
)
# This will request
# https:/api.server.com/v1/users/?parent=%00