Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Servicenow Table API
#3
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
Reply


Messages In This Thread
Servicenow Table API - by bdpy9 - Mar-10-2020, 08:04 PM
RE: Servicenow Table API - by buran - Mar-10-2020, 08:10 PM
RE: Servicenow Table API - by bdpy9 - Mar-10-2020, 08:29 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020