Skip to content

Instantly share code, notes, and snippets.

@bryanbarnard
Last active January 1, 2016 11:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanbarnard/8139495 to your computer and use it in GitHub Desktop.
Save bryanbarnard/8139495 to your computer and use it in GitHub Desktop.
Sample Requests Python ServiceNow JSONv2 - GetIncident
##Sample HTTP Request to ServiceNow Demo Instance Using JSONv2 Web Service
import requests
from requests.auth import HTTPBasicAuth
#using local http proxy to log requests and responses
proxies = {
"http": "http://127.0.0.1:8888",
"https": "https://127.0.0.1:8888",
}
auth = HTTPBasicAuth("admin", "admin")
uri = "https://demo006.service-now.com/incident.do?JSONv2&sysparm_sys_id=d71f7935c0a8016700802b64c67c11c6"
headers = {
"accept": "application/json;charset=utf-8",
"Content-Type": "application/json",
}
r = requests.get(url=uri, auth=auth, proxies=proxies, verify=False, headers=headers)
content = r.json()
print "Response Status Code: " + str(r.status_code)
print "Response JSON Content: " + str(content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment