Forum Discussion
Ring_Test
5 years agoContributor
import requests
params = {'fromDate': startdate , # Set the start date in YYYYMMDD format
'toDate': enddate }
headers = {'client-id': client_id ,
###TODOplace the "Client ID" from LSI here
'Accept': 'application/json'
}
url = '' ### URL can be obtained from sample curl command in lithium community page
response = requests.get(
url,
params=params,
auth =(access_token, ''),
headers = headers # OPTIONAL: this could also be set to "application/json" to receive JSON results, or even left unset to receive CSV
)
#data = response.json()
# Use "response.json()" incase you need json response (set 'Accept' header as mentioned above).
print(response.headers)
print(response.url)
filename ='C:\<directory>\getdata.json' ### JSON file you can define where you want to put data
with open(filename, 'wb') as fd:
for chunk in response.iter_content(chunk_size=128):
fd.write(chunk)
Related Content
- 5 months ago
- 2 years ago
- 10 years ago