Bulk API request using python failing
I have tried both the examples recommended for python and both are failing with different errors.
access_token = "<my api token>" # Place the "Bulk API access token" from Community Analytics here
client_id = "my client id" # Place the "Client ID" from Community Analytics here
response = requests.get(
'https://api.lithium.com/lsi-data/v1/data/export/community/communityid',
params={'fromDate': '20210630', # Set the start date in YYYYMMDD format
'toDate': '20210707'}, # Set the end date in YYYYMMDD format
auth=(access_token, ''),
headers={'client-id': client_id,
'Accept': 'application/json' }
data = response.json()
print(data)
Output:
SSLError: HTTPSConnectionPool(host='api.lithium.com', port=443): Max retries exceeded with url: /lsi-data/v1/data/export/community/communityid?fromDate=20210630&toDate=20210707 (Caused by SSLError(SSLError(9, '[X509] PEM lib (_ssl.c:4109)')))
request = urllib2.Request("https://api.lithium.com/lsi-data/v1/data/export/community/communityid?fromDate=20210701&toDate=20210707")
base64string = base64.b64encode(('%s:' % access_token).encode('utf-8'))
request.add_header("Authorization", "Basic %s" % base64string)
request.add_header("client-id", client_id)
request.add_header("Accept", "application/json")
response = urllib2.urlopen(request)
print(response.read())
Output:
---> 10 response = urllib2.urlopen(request)
HTTPError: HTTP Error 500: Internal Server Error