Last active
August 29, 2015 14:17
-
-
Save CTimmerman/9fb992202a5b6ed3f790 to your computer and use it in GitHub Desktop.
HTTPS POST SRXP API example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests # python-requests.org | |
url = 'https://portal.srxp.com/api/1/access_keys' | |
post_data = {'email':'xxx', 'password':'xxx'} | |
response = requests.post(url, json=post_data) | |
try: | |
json = response.json() | |
print("Key: " + json['access_key']) | |
except: | |
print("Error: %s" % response.status_code) | |
print(response.text) | |
""" e.g. | |
Error: 404 | |
{"code":404,"message":"Not Found"} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was struggling with bad request errors using the HTTP mess that comes with Python.