send arrays over post by python requests library

Solutions on MaxInterview for send arrays over post by python requests library by the best coders in the world

showing results for - "send arrays over post by python requests library"
Monica
14 Jan 2018
1import requests
2url= "path/to/api"
3# Final Payload -> payload = {'key1': 'value1', 'key2': 'value2', 'keys[0]': 's1', 'keys[1]': 's2', 'keys[2]': 's3', 'keys[3]': 's4', 'keys[4]': 's5'}
4keys=['s1','s2','s3','s4','s5']
5data={'key1': 'value1', 'key2': 'value2', 'keys[]': keys}
6r = requests.post(url, data)
7res = r.json()
8print(res)
similar questions