import requests
def fetch_data(url, api_key):
try:
# Set up the headers, including the Authorization header
headers = {
'Authorization': f'LMC-API-KEY {api_key}', # Add your API key here
'Content-Type': 'application/json', # Optional: specify content type
}
# Make the GET request
response = requests.get(url, headers=headers)
response.raise_for_status() # Raises an HTTPError for bad responses
# Parse the JSON response
data = response.json()
print('Data received:', data)
except requests.exceptions.HTTPError as http_err:
print(f'HTTP error occurred: {http_err}')
except Exception as err:
print(f'Other error occurred: {err}')
if __name__ == "__main__":
account_id = '8be7cc82...' # Replace with your account's ID
endpoint = f'https://cloud.lancom.de/cloud-service-devices/accounts/{account_id}/sites'
api_key = 'ey...aNzo' # Replace with your actual API key
fetch_data(endpoint, api_key)