Use requests
library to GET, POST, PUT or DELETE by hitting a REST API endpoint. Pass the rest api endpoint url in url
, payload(dict) in data
and header/metadata in headers
import requests, json
url = "bugs.python.org"
payload = {"number": 12524,
"type": "issue",
"action": "show"}
header = {"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"}
response_decoded_json = requests.post(url, data=payload, headers=header)
response_json = response_decoded_json.json()
print response_json