This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to batch edit uploaded activities?

Hi,

I've uploaded my activities from Strava (about 700) via bulk export (as archive). Now I can see them under activities, but they are all uncatogorized. How do I have to upload the files to get the right sport type? Or is there any possibility to do a batch change of the activity type?

  • and thank you so much!! Your codes saved me having to go through 5 years of running activities = hours of mindless mouse clicking.

  • Does anyone have a link to the list of activity types?

    ... as they have to be used in the scripts.

  • Hi,

    I upgraded from Venu to Venu 3 a couple of months ago. I'm using it mostly for HIIT activities. Venu didn't support HIIT so I used the Train program and those activities are registered under the "Other" activity type. I would like to change this activity type to "HIIT". 

    Has anyone managed to do this (maybe via export, change, import)? There are hundreds of such activities, so manual clicking and changing is not an option.

  • More recent version was here, but also needs some change.

    Updated F12 → Console script

    set limit=1 as needed (latest activities)
    add filters from the advanced search like &activityType=other
    setTimeout 2000 is wait time

    Run search script and check if prints correct results.

    h={
     'DI-Backend':'connectapi.garmin.com',
     'Authorization':'Bearer '+JSON.parse(localStorage.token).access_token
    }

    t=0
    jQuery.ajax({
     headers: h,
     url: 'https://connect.garmin.com/activitylist-service/activities/search/activities?limit=1&activityType=other',
     success: all => all.forEach(async a=>{
       await new Promise(s=>setTimeout(s,t+=2000))
       console.dir(a.activityId, a.activityName, a.startTimeLocal)
      })
    })

    add edit request inside the loop, new line after console.dir
    set "typeKey":"hiit" as needed

    fetch('https://connect.garmin.com/activity-service/activity/' + a.activityId,
    {
     'headers': {...h, 'Content-Type': 'application/json', 'X-HTTP-Method-Override': 'PUT'},
     'body': '{"activityTypeDTO":{"typeKey":"hiit"}}',
     'method': 'POST'
    })

  • Hi ,

    thanks for this.

    In my browser (chrome) it does cycle through all "other" activities, but it does not change them to "running". Error message: "a is not defined at <anonymous>" Any ideas? Thanks a lot.

  • The fetch should be at new line after console.dir but still inside the brackets of a=>{ ... } as those limit where a variable is readable.

    As it lists activities using the same a, then it works, so make sure you paste edit there.

  • Now I get it. Thanks

    Adding gear also worked with replacing the fetch like this

    fetch('https://connect.garmin.com/gear-service/gear/link/YOURGEARID/activity/' + a.activityId,
    {
        'headers': {...h, 'Content-Type': 'application/json', 'X-HTTP-Method-Override': 'PUT'},
        'method': 'POST'
    })

  • Bulk edit all activities between dates to assign a piece of gear to them.

    // EDIT ALL GEAR between dates
    console.log(JSON.parse(localStorage.token).access_token)
    GT2000ID = '401db7e05626493f912bb6cc53283d83'
    h={
     'DI-Backend':'connectapi.garmin.com',
     'Authorization':'Bearer '+JSON.parse(localStorage.token).access_token
    };
    jQuery.ajax({
     headers: h,
     url: 'https://connect.garmin.com/activitylist-service/activities/search/activities?activityType=running&startDate=2019-09-15&endDate=2020-01-04&limit=50&start=0&_=1577777388000',
     success: function(act_list) {
        act_list.forEach(
            function(act){
                 jQuery.ajax({
                     headers: {...h, 'Accept': 'application/json'},
                     timeout: 1000,
                     url:'/gear-service/gear/link/'+ GT2000ID + '/activity/' + act['activityId'],
                     method: 'PUT',
                     complete: function(xhr, textStatus) {
                         console.log(act['activityId'], xhr.status);
                     }
                });
            })
            }
    });

    Uploaded a few more scripts here: https://github.com/lucagiovagnoli/garmin_tools/blob/main/garmin_gear/bulk_edit_activity_gear.js

  • You can use headers: {...h, additional-header} to add some header to already defined headers in h, like above, not to double values. Though, often some headers are optional and it works also without them, so good to check which are required.

    Also probably better to add wait time, some requests may have time limit.

  • Thank you for the suggestions! Updated