Advertisement
Guest User

Untitled

a guest
Sep 5th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. """
  2. https://stackoverflow.com/a/9746432/496445
  3. """
  4. import json
  5. import urllib.request
  6.  
  7. data = {
  8.     'ids': [12, 3, 4, 5, 6]
  9. }
  10.  
  11. req = urllib.request.Request('http://example.com/api/posts/create')
  12. req.add_header('Content-Type', 'application/json')
  13.  
  14. response = urllib.request.urlopen(req, json.dumps(data).encode('utf8'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement