If your server expects the POST request to be json, you need to add a header as well as serialize the data for your request ...
Python 2.x
import json import urllib2 data = { 'ids': [12, 3, 4, 5, 6] } req = urllib2.Request('http://example.com/api/posts/create') req.add_header('Content-Type', 'application/json') response = urllib2.urlopen(req, json.dumps(data))
Python 3.x
stack overflow
If you do not specify a title, this will be the default type application/x-www-form-urlencoded .
jdi Mar 17 '12 at 1:19 2012-03-17 01:19
source share