GET Request for GPX "Resource not found" Strava API

Viewed 422

Following Stravas API instructions Export Route GPX (getRouteAsGPX), we do not get the gpx file.

The code we used is:

import requests
import urllib3
import gpxpy
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

auth_url = "https://www.strava.com/oauth/token"
activites_url = "https://www.strava.com/api/v3/athlete/activities"
gpx_url= "https://www.strava.com/api/v3/routes/%s/export_gpx" .format(4947441661)


access_token = "XXXXXXXXXXXXXXXXXXXXXXXX"
print("Access Token = {}\n".format(access_token))

header = {'Authorization': 'Bearer ' + access_token}
param = {'per_page': 200, 'page': 1}
response = requests.get(gpx_url, headers=header, params=param).json()

We receive a dic back, but without the gpx file. {'message': 'Resource Not Found', 'errors': []}

Has anyone succesfully retrieved the gpx file lately? Any suggestions what the problem might be?

1 Answers

Replacing your gpx_url line with the line below did the trick for me. Make sure you have access to route 4947441661 and have the appropriate scope (read_all).

gpx_url= "https://www.strava.com/api/v3/routes/%s/export_gpx" % 4947441661
Related