Skip to content

Instantly share code, notes, and snippets.

@GaretJax
Last active August 29, 2015 14:12
Show Gist options
  • Save GaretJax/9b0d6ce0ea61feb24449 to your computer and use it in GitHub Desktop.
Save GaretJax/9b0d6ce0ea61feb24449 to your computer and use it in GitHub Desktop.
import logging, requests, pprint
# Setup logging
logging.basicConfig(level=logging.DEBUG)
base = 'https://<instance>.atlassian.net'
username = 'user'
password = '******'
session = requests.Session()
session.auth = (username, password)
# Get the server info
url = base + '/rest/api/2/serverInfo'
r = session.get(url)
pprint.pprint(r.json())
# Get an issue
url = base + '/rest/api/2/issue/CUA-1'
r = session.get(url)
pprint.pprint(r.json())
import logging, requests, pprint
# Setup logging
logging.basicConfig(level=logging.DEBUG)
base = 'https://<instance>.atlassian.net'
username = 'user'
password = '******'
session = requests.Session()
session.auth = (username, password)
# Get the server info
url = base + '/rest/api/2/serverInfo'
r = session.get(url)
pprint.pprint(r.json())
# Get an issue
url = base + '/rest/api/2/issue/CUA-1'
r = session.get(url)
pprint.pprint(r.json())
# Logout
url = base + '/rest/auth/1/session'
r = session.delete(url, headers=headers)
pprint.pprint(r.status_code)
import requests
import pprint
import logging
from requests.cookies import RequestsCookieJar
logging.basicConfig(level=logging.DEBUG)
class ObliviousCookieJar(RequestsCookieJar):
def set_cookie(self, *args, **kwargs):
"""Simply ignore any request to set a cookie."""
pass
def copy(self):
"""Make sure to return an instance of the correct class on copying."""
return ObliviousCookieJar()
base = 'https://<instance>.atlassian.net'
username = 'user'
password = '******'
session = requests.Session()
session.cookies = ObliviousCookieJar()
session.auth = (username, password)
# Get the server info
url = base + '/rest/api/2/serverInfo'
r = session.get(url)
pprint.pprint(r.json())
# Get an issue
url = base + '/rest/api/2/issue/CUA-1'
r = session.get(url)
pprint.pprint(r.json())
import logging, requests, pprint
# Setup logging
logging.basicConfig(level=logging.DEBUG)
base = 'https://<instance>.atlassian.net'
username = 'user'
password = '******'
session = requests.Session()
session.auth = (username, password)
# Get the server info
url = base + '/rest/api/2/serverInfo'
r = session.get(url)
pprint.pprint(r.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment