As Django Test Client accepts only data={} as an input I am not able to pass a list of dict i.e data=[{},{},{}] to it. Any solution for this?
This worked:
response = client.post(url, json.dumps(data), content_type='application/json')
You can pass the values as a list in the dict:
data={"key": [{"key":"value"}, {"key":"value"}]}
Alternatively you can use a MultiValueDict as the value.
You can pass as a list also
import requests
data = [{"key":"value"}, {"key":"value"}]
a = requests.post('http://url', data)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With