Trying to make a workout planner with python but having massive issues with a 403 error. Even in the API documentation when I try to delete workouts with the right user ID and date range, the error keeps coming back (both Auth methods used)
This first. Then here is the snippet I`m working on in Python:
-------------------
Delete existing events safely
-------------------
def delete_events(start_date, end_date):
“”“Fetch all events in range and delete individually”“”
url = f"{BASE_URL}athlete/{ATHLETE_ID}/events"
params = {
“start_date_local”: start_date.isoformat(),
“end_date_local”: end_date.isoformat(),
“category”: “WORKOUT”
}
resp = requests.get(url, headers=HEADERS, auth=AUTH, params=params)
if resp.status_code != 200:
print(f"
Failed to fetch events: {resp.status_code} {resp.text}“)
return
events = resp.json()
for ev in events:
ev_id = ev[“id”]
del_url = f”{BASE_URL}athlete/{ATHLETE_ID}/events/{ev_id}"
del_resp = requests.delete(del_url, headers=HEADERS, auth=AUTH)
if del_resp.status_code in (200, 204):
print(f"
Deleted event {ev_id}“)
else:
print(f"
Failed to delete event {ev_id}: {del_resp.status_code} {del_resp.text}”)
Unfortunately always getting back a 403.. In Python I only used the bearer token.
