admin-dashboard-backend/groupTasks/groups/shx-manual-fetch-product-pi.../script.py

23 lines
948 B
Python

import sys
import requests
try:
with open('../../secrets/admin-dashboard-api-key.txt') as f:
adminDashboardApiKey = f.read().strip() # `.strip()` to remove any extra whitespace or newlines
except FileNotFoundError:
sys.exit("Error: API key file not found.")
except Exception as e:
sys.exit(f"Error reading the API key file: {e}")
try:
res = requests.get("https://devdash.ex.umbach.dev/api/v1/productpipeline/update",
headers={"X-Api-key": adminDashboardApiKey})
res.raise_for_status() # Raises a HTTPError if the HTTP request returned an unsuccessful status code
except requests.exceptions.HTTPError as http_err:
sys.exit(f"HTTP error occurred: {http_err}") # HTTP error
except requests.exceptions.RequestException as err:
sys.exit(f"Error occurred: {err}") # Other errors
except Exception as e:
sys.exit(f"An unexpected error occurred: {e}")
print(f"Response text: {res.text}")