Servicenow Table API - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Servicenow Table API (/thread-24921.html) |
Servicenow Table API - bdpy9 - Mar-10-2020 Good Afternoon, I need to write python code to get last 5 days of data from ServiceNow Table API for example sc_req_item table. can anyone help me to build the method with headers, parameters and response. RE: Servicenow Table API - buran - Mar-10-2020 Welcome to the forum. We are glad to help, but we are not going to write code for you. There is nice documentation with python examples. So it's a good place to start. Write some code and when you face problem - come here and ask specific question. Always post your code in python tags, full traceback (if any) - in error tags. RE: Servicenow Table API - bdpy9 - Mar-10-2020 Here is my method: I have two tasks now 1. i need to pass delta_dt some where to get last five days of data by sys_updated_on 2. i need to write if condition to go for loadtype as full or incremental. In incremental i need to get last 5 days of data. def call_api_get_total_record_count(url, username, password, loadtype): delta_dt = (date.today() - timedelta(days=5)).isoformat() headers = {"Content-Type": "application/json", "Accept": "application/json"} parameters_full = {"sysparm_limit": "1"} parameters_incremental = {"sysparm_limit": "1", "sysparm_query": "sys_updated_on"} response = requests.get(url, auth=(username, password), headers=headers, params=parameters) totalrecordcount = int(response.headers['X-Total-Count']) return totalrecordcountthis code is to retrieve total count of rows either for full load or last 5 days of incremental load |