Looking for the best way to ingest data from ServiceNow using the REST API and write the output as tables to AWS.
Im able to retrieve data as JSON from ServiceNow instance using Python, how can I write these tables in S3 as data frame?
I have seen some examples with pandas but those used a JSON file, I just want to write the output that is shown as JSON (the answer from ServiceNow) and convert it to a table and then save the tables in a S3 bucket.
I have some data in several tables that I would like to export as a dataframe( or CSV ) to a S3 bucket using Python and the REST API.
Here is the code:
import json
import pandas as pd
import requests
url = "https://corp.service-now.com/api/now/table/xx_strrt_demand?sysparm_display_value=all&sysparm_exclude_reference_link=true&sysparm_limit=10&sysparm_offset"
payload={}
headers = {
'Authorization':
'Basic UG93ZXJC2SUtZzpDM1BTNF9LLJTkdh',
'Cookie':
'BIGipServerpool_corp=a5578555e3ff9123; JSESSION7EA125; glide_session_store=AACD91038A20B87536D439A; glide_user_route=glide.57a533c51e6a19742f22d0
}
response = requests.request("GET", url,
headers=headers,
data=payload)
print(response.text)
The response:
{"result":[{“organization":{"display_value”:"City","value":"da10d7c7d200f6579543990ebd"},"dev_tref":{"display_value":"Entree","value":"engewrewng"},"dearth":{"display_value":"11/03/2015 00:00:00","value":"2015-03-10 23:00:00"},"dert_domain_path":{"display_value":"!!4/","value":"!!4/"},"detitle":{"display_value":"Recover (Unit SL2)","value":"RDense LPG greet (Analyzer SH345)"},"demar_names":"others"}