tags:

views:

101

answers:

1

Hi, can anyone point out a tutorial that shows me how to do a POST request using urllib2 with the data being in JSON format?

+2  A: 

Example - sending some data encoded as JSON as a POST data:

import json
import urllib2
data = json.dumps([1, 2, 3])
f = urllib2.urlopen(url, data)
response = f.read()
f.close()
Messa