Python ‐ SNOW Incident Creation API - shubhamsayon/SNOW-API GitHub Wiki
# Need to install requests package for python
# easy_install requests
import requests
# Set the request parameters
url = 'https://dev194827.service-now.com/api/now/import/u_postman_inbound_integration'
# Eg. User name="admin", Password="admin" for this code sample.
user = 'admin'
pwd = 'admin'
# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}
# Do the HTTP request
response = requests.post(url, auth=(user, pwd), headers=headers ,data="{\"u_requested_for\":\"System Administrator\",\"u_short_description\":\"I need to upgrade my Antivirus\",\"u_email_id\":\"[email protected]\",\"u_incident_state\":\"2\"}")
# Check for HTTP codes other than 200
if response.status_code != 200:
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
exit()
# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)