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.
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.
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 totalrecordcount
this code is to retrieve total count of rows either for full load or last 5 days of incremental load