1
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?

2 Answers 2

4

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)
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.