import requests
qp_args = {"query_params": {"list1": [], "list2": [], "list3": [],
"data": "something"}}
data = requests.get(url="Service URL", params = qp_args, timeout=2)
# This doesn't work for me, since the client is receiving query_params in chunks, like,
# url/?query_params=list1&query_params=list2&query_params=list3&query_params=data
what is the correct way to send nested dictionary in the query_params in request.get?
CodePudding user response:
You can try this
import json
import requests
query_params = {
"list1": [],
"list2": [],
"list3": []
}
qp_args = {
"query_params": json.dumps(query_params),
"data": "something"
}
data = requests.get(url="Service URL", params = qp_args, timeout=2)
CodePudding user response:
Just try as documentation points out in this link
payload = {'key1': 'value1', 'key2': ['value2', 'value3']}
r = requests.get('https://httpbin.org/get', params=payload)
print(r.url)
# https://httpbin.org/get?key1=value1&key2=value2&key2=value3