Skip to content

Instantly share code, notes, and snippets.

@CTimmerman
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CTimmerman/9fb992202a5b6ed3f790 to your computer and use it in GitHub Desktop.
Save CTimmerman/9fb992202a5b6ed3f790 to your computer and use it in GitHub Desktop.
HTTPS POST SRXP API example
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"}
"""
@CTimmerman
Copy link
Author

I was struggling with bad request errors using the HTTP mess that comes with Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment