cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

The Hub is now in read-only mode as we make improvements to the Hub experience. More information is available here.

updateActivityById - Resource Not Found Error

eioaa
Mt. Kenya

Hi,

I'm trying to update an activity using the endpoint updateActivityById with a PUT request in Python. However, I'm consistently getting a "Resource Not Found" error. Here's my code:

 

def update_acti(idd):
   activity_write_read_all_token = ***

    url = f'https://www.strava.com/api/v3/activities/{idd}'
    
    header = {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer ' + activity_write_read_all_token
        }
    
    data = {
        'gear_id' : user['shoes'] #shoes identifier, string
        }
    
    r = requests.put(url, headers = header, json = data).json()
    return r

response = update_acti(***)

 

I get an error 404 : Ressource Not Found.

I first checked that the activity existed with getActivityById and it does. The user['shoes'] returns the correct gear id as a string. Even with this line commented I still get the error.

Then I supposed the error came from my PUT request "syntax" or from the access token. So I tested the updateActivityById  endpoint using the Swagger Playground. Considering the scope issue in the playground I used a public activity requiring only the activity:write scope. And once again I got a 404 : Ressource Not Found.

I am all out of ideas to solve this so if you have a clue on what could be the problem on my part or if it could be a bug on the endpoint, I'd be glad to hear it. Thanks.

3 REPLIES 3

Jan_Mantau
Superuser
Superuser

I don't know anything about Python, but shouldn't there be a command where the placeholder {idd} is replaced by the activity id?

This display isn't showing the formatting, but they are using an f string. The variable name surrounded by brackets will replace that part of the string with the idd variable.  https://www.geeksforgeeks.org/formatted-string-literals-f-strings-python/

arobbins530
Shkhara

Not sure if you're still seeing this problem, but I was as well. I was able to solve it by simply adding gear_id into the body of the Create Activity call (which is weird since the API does not list that as a valid option for that endpoint... but it works)