Skip to main content
update pip install
Source Link
radtek
  • 36.6k
  • 13
  • 149
  • 114

You can use the requests library, it simplifies things a lot in comparison to taking the urllib2 approach. First install it from pip:

pip install requestrequests 

More on installing requests.

Then setup the put request:

import requests import json url = 'https://api.github.com/some/endpoint' payload = {'some': 'data'} # Create your header as required headers = {"content-type": "application/json", "Authorization": "<auth-key>" } r = requests.put(url, data=json.dumps(payload), headers=headers) 

See the quickstart for requests library. I think this is a lot simpler than urllib2 but does require this additional package to be installed and imported.

You can use the requests library, it simplifies things a lot in comparison to taking the urllib2 approach. First install it from pip:

pip install request 

More on installing requests.

Then setup the put request:

import requests import json url = 'https://api.github.com/some/endpoint' payload = {'some': 'data'} # Create your header as required headers = {"content-type": "application/json", "Authorization": "<auth-key>" } r = requests.put(url, data=json.dumps(payload), headers=headers) 

See the quickstart for requests library. I think this is a lot simpler than urllib2 but does require this additional package to be installed and imported.

You can use the requests library, it simplifies things a lot in comparison to taking the urllib2 approach. First install it from pip:

pip install requests 

More on installing requests.

Then setup the put request:

import requests import json url = 'https://api.github.com/some/endpoint' payload = {'some': 'data'} # Create your header as required headers = {"content-type": "application/json", "Authorization": "<auth-key>" } r = requests.put(url, data=json.dumps(payload), headers=headers) 

See the quickstart for requests library. I think this is a lot simpler than urllib2 but does require this additional package to be installed and imported.

deleted 1 character in body
Source Link
radtek
  • 36.6k
  • 13
  • 149
  • 114

You can use the requests library, it simplifies things a lot in comparison to taking the urllib2 approach. First install it from pip:

pip install request 

More on installing requests.

Then setup the put request:

import requests import json url = 'https://api.github.com/some/endpoint' payload = {'some': 'data'} # Create your header as required headers = {"content-type": "application/json", "Authorization": "<auth-key>" } r = requests.postput(url, data=json.dumps(payload), headers=headers) 

See the quickstart for requests library. I think this is a lot simpler than urllib2 but does require this additional package to be installed and imported.

You can use the requests library, it simplifies things a lot in comparison to taking the urllib2 approach. First install it from pip:

pip install request 

More on installing requests.

Then setup the put request:

import requests import json url = 'https://api.github.com/some/endpoint' payload = {'some': 'data'} # Create your header as required headers = {"content-type": "application/json", "Authorization": "<auth-key>" } r = requests.post(url, data=json.dumps(payload), headers=headers) 

See the quickstart for requests library. I think this is a lot simpler than urllib2 but does require this additional package to be installed and imported.

You can use the requests library, it simplifies things a lot in comparison to taking the urllib2 approach. First install it from pip:

pip install request 

More on installing requests.

Then setup the put request:

import requests import json url = 'https://api.github.com/some/endpoint' payload = {'some': 'data'} # Create your header as required headers = {"content-type": "application/json", "Authorization": "<auth-key>" } r = requests.put(url, data=json.dumps(payload), headers=headers) 

See the quickstart for requests library. I think this is a lot simpler than urllib2 but does require this additional package to be installed and imported.

json spec does not like single quotes
Source Link
radtek
  • 36.6k
  • 13
  • 149
  • 114

You can use the requests library, it simplifies things a lot in comparison to taking the urllib2 approach. First install it from pip:

pip install request 

More on installing requests.

Then setup the put request:

import requests import json url = 'https://api.github.com/some/endpoint' payload = {'some': 'data'} # Create your header as required headers = {'content"content-type'type": 'application"application/json'json", 'Authorization'"Authorization": '<auth"<auth-key>'key>" } r = requests.post(url, data=json.dumps(payload), headers=headers) 

See the quickstart for requests library. I think this is a lot simpler than urllib2 but does require this additional package to be installed and imported.

You can use the requests library, it simplifies things a lot in comparison to taking the urllib2 approach. First install it from pip:

pip install request 

More on installing requests.

Then setup the put request:

import requests import json url = 'https://api.github.com/some/endpoint' payload = {'some': 'data'} # Create your header as required headers = {'content-type': 'application/json', 'Authorization': '<auth-key>' } r = requests.post(url, data=json.dumps(payload), headers=headers) 

See the quickstart for requests library. I think this is a lot simpler than urllib2 but does require this additional package to be installed and imported.

You can use the requests library, it simplifies things a lot in comparison to taking the urllib2 approach. First install it from pip:

pip install request 

More on installing requests.

Then setup the put request:

import requests import json url = 'https://api.github.com/some/endpoint' payload = {'some': 'data'} # Create your header as required headers = {"content-type": "application/json", "Authorization": "<auth-key>" } r = requests.post(url, data=json.dumps(payload), headers=headers) 

See the quickstart for requests library. I think this is a lot simpler than urllib2 but does require this additional package to be installed and imported.

Source Link
radtek
  • 36.6k
  • 13
  • 149
  • 114
Loading