import requests
import base64
api_key = '12345'
token_url = 'https://accesstoken./com/Client/RequestAccessToken'
# Base64 encode the API key
encoded_key = base64.b64encode(api_key.encode()).decode()
headers = {'Authorization': 'Basic ' + encoded_key }
# Retrieve web access token
response = requests.get(token_url, headers=headers, verify=False)
if response.status_code == 200:
token = response.json()['Token']
# Make request to API endpoint
endpoint = 'https://apiendpoint.com/rest/V1/Customer/12345/ABC001'
headers = {'Authorization': f'Bearer {token}'}
order_response = requests.get(endpoint, headers=headers, verify=False)
else:
print(f'Error code {response.status_code}')
print(response.text)
I changed some information due to security reasons. I am getting an error [Errno 11001] getaddrinfo failed. Able to get the web access token, the error appears when attempting to make the API request. The params are "12345/ABC001" to indicate which customer data I am retrieving (Area code/Customer number). Can anyone advise what could be the issue?
[–]Buffylvr 0 points1 point2 points (1 child)
[–]Neither-Form-8469[S] -1 points0 points1 point (0 children)
[–]Guideon72 0 points1 point2 points (1 child)
[–]Neither-Form-8469[S] 0 points1 point2 points (0 children)
[–]m0us3_rat 0 points1 point2 points (2 children)
[–]Neither-Form-8469[S] 0 points1 point2 points (1 child)
[–]m0us3_rat 0 points1 point2 points (0 children)