data = {'ids': [12, 3, 4, 5, 6]}
req = urllib.request.Request('http://example.com/api/posts/create')
req.add_header('Content-Type', 'application/json')
response = urllib.request.urlopen(req, json.dumps(data))
Как отправить запрос POST в формате JSON?