- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-29-2018 01:42 PM
Right now this is my working code
import requests
import json
# Set the request parameters
url = 'https://instance.service-now.com/api/now/table/incident'
# Eg. User name="admin", Password="admin" for this code sample.
user = 'user'
pwd = 'password'
# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}
# Do the HTTP request
response = requests.get(url, auth=(user, pwd), headers=headers )
# 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)
My question is how do I set a filter on the data that comes back using these conditions sysparm_query=active=true^state!=6
Im using python to retrieve the data, any help would be much appreciated.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-29-2018 02:56 PM
you can add filter directly to call so all results will be filtered.
url = 'https://instance.service-now.com/api/now/table/incident?sysparm_query=active%3Dtrue%5Estate!%3D6
Doc - https://developer.servicenow.com/app.do#!/rest_api_doc?v=jakarta&id=r_TableAPI-GET

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-29-2018 02:56 PM
you can add filter directly to call so all results will be filtered.
url = 'https://instance.service-now.com/api/now/table/incident?sysparm_query=active%3Dtrue%5Estate!%3D6
Doc - https://developer.servicenow.com/app.do#!/rest_api_doc?v=jakarta&id=r_TableAPI-GET