Skip to content

Instantly share code, notes, and snippets.

@schadr
Created August 30, 2012 20:41
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 schadr/3540382 to your computer and use it in GitHub Desktop.
Save schadr/3540382 to your computer and use it in GitHub Desktop.
Shows how to requests the content for a URI from a Jazz server, including authentication with the server, using the request lib for python
import requests
user= 'your jazz username'
pw = 'your jazz password'
host = 'https://jazzhost:port/something'#/ROOTSERVICES
resource_uri = 'https://jazzhost:port/some_uri.json'
r = requests.get(host + '/authenticate/identidty', headers={'Accept':'application/xml'}, allow_redirects=True, verify=False)
r = requests.post(host + '/j_security_check', allow_redirects=True, verify=False, data={'j_username':user,'j_password':pw}, cookies=r.cookies)
r = requests.get( resource_uri, allow_redirects=True, verify=False, cookies=r.cookies)
r.json# contains the json response as dictionary of lists/diciotnaries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment