bryanbarnard
12/26/2013 - 10:23 PM

Sample Requests Python ServiceNow JSONv2 - GetIncident

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)