data = {
'ids': [12, 3, 4, 5, 6 , ...]
}
urllib2.urlopen("http://abc.example/api/posts/create",urllib.urlencode(data))
I want to send a POST request, but one of the fields should be a list of numbers. How can I do that? (JSON?)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If your server is expecting the POST request to be json, then you would need to add a header, and also serialize the data for your request…
Python 2.x
Python 3.x
https://stackoverflow.com/a/26876308/496445
If you don’t specify the header, it will be the default
application/x-www-form-urlencodedtype.