Background
- python 2.7
- requests module
- http post with duplicate keys to specify multiple values
Problem
Trevor is using python requests with a website that takes duplicate keys to specify multiple values. The problem is, JSON and Python dictionaries do not allow duplicate keys, so only one of the keys makes it through.
Goal
- The goal is to use python requests to create an HTTP post with duplicate keys for duplicate names in the POST name-value pairs.
Failed attempts
## sample code
payload = {'fname': 'homer', 'lname': 'simpson'
, 'favefood': 'raw donuts'
, 'favefood': 'free donuts'
, 'favefood': 'cold donuts'
, 'favefood': 'hot donuts'
}
rtt = requests.post("http://httpbin.org/post", data=payload)
See also
Web links:
Question
- How can Trevor accomplish this task using python requests?