Get last 15 mins of created incident using snow API using Python
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 03:33 AM
I am using the below code to get the list of incident created in last 15 mins but its giving all the incident (10000), created in last 6 month, any help will be appreciated.
import requests
def get_recent_incidents(instance_url, username, password😞
api_endpoint = f"{instance_url}/api/now/table/incident? sysparm_query=sys_created_onRELATIVELE%40minute%40ago%4015"
response = requests.get(api_endpoint, auth=(username, password))
if response.status_code == 200:
return response.json()['result']
else:
print(f"Error fetching incidents: {response.text}")
return []
username = "admin"
password = "admin"
recent_incidents = get_recent_incidents(instance_url, username, password)
print(recent_incidents)
0 REPLIES 0