import requests
def fetch_data(url, api_key):
try:
headers = {
'Authorization': f'LMC-API-KEY {api_key}', # Add your API key here
'Content-Type': 'application/json', # Optional: specify content type
}
response = requests.get(url, headers=headers)
if response.status_code != 200:
raise Exception(f'HTTP error! Status: {response.status_code}')
# Parse the JSON response
data = response.json()
print('Data received:', data)
except Exception as error:
print('Error fetching data:', error)
account_id = '8be7cc82...' # Replace with your account's ID
site_name = 'test_site'
model_name = 'LX-6400'
state = 'INACTIVE'
endpoint = f'https://cloud.lancom.de/cloud-service-devices/accounts/{account_id}/devices?site.nameLike={site_name}&status.modelILike={model_name}&status.heartbeatState={state}'
api_key = 'ey...aNzo' # Replace with your actual API key
fetch_data(endpoint, api_key)