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?

  • If you are handy there are people that have written scripts for this - e.g. https://forums.garmin.com/apps-software/mobile-apps-web/f/garmin-connect-web/165458/is-there-a-way-to-change-activity-category-in-a-large-batch - but there is no natively ability in Garmin Connect for it. The best you can do, I believe, is listing all activities in the overview (https://connect.garmin.com/modern/activities) and changing them from that list.

  • Activities' type can be changed like in this script.

    Login to Connect and use in web-browser console (F12), tested in Firefox.

    .

    Set limit=2 as needed, this will change 2 latest activities to running.

    Change "typeKey" if you need other type.

    If there are different types - add some IF conditions to check for dates or distances or something.

    .

    jQuery.getJSON(
        'https://connect.garmin.com/modern/proxy/activitylist-service/activities/search/activities?limit=2',
        function(act_list)
        {
            act_list.forEach(
            function(act)
                {
                    fetch('https://connect.garmin.com/modern/proxy/activity-service/activity/' + act['activityId'],
                    {
                        'headers': { 'Content-Type': 'application/json', 'NK': 'NT', 'X-HTTP-Method-Override': 'PUT' },
    
                        'body': '{"activityTypeDTO":{"typeId":6,"typeKey":"running","parentTypeId":1,"sortOrder":6},"activityId":' + act['activityId'] + '}',
    
                        'method': 'POST'
                    });
                    console.dir(act['activityId'], act['activityName'], act['startTimeLocal']);
                }
            );
        }
    );

  • Thanks for the nudge in the right direction. Never thought of using developer tools and jQuery but that was very useful when bulk importing from Strava today.

    Some additional pointers:

    1) below code update only categorizes currently uncategorized. That is much more helpful as it prevents you overwriting your other sports all with "running", as in the above example.

    2) if you batch import, do it one sport at a time. That way, you can first import e.g. running, assign it all to running (because they are uncatagorized), then import the next sport and assign only those etc.

    3) you can similarly, in the same call, map it to your gear. For that you need the UUID of the gear, and make sure it was "active" at the time of the event you want to assign (otherwise, first fix the start date of your gear as explained here: https://forums.garmin.com/apps-software/mobile-apps-web/f/garmin-connect-web/124908/new-gear-date---why-can-t-i-edit-this/1070979#1070979). You can find your UUID by navigating to your gear in connect, click edit. It will be the 32 characters in your address bar: https://connect.garmin.com/modern/gear/YOURUUIDHERE/edit

    4) to find the right "body" statement for other sports, what I do is use the F12 console and monitor the request that gets fired if you manually change an activity. For type change, you need to change much more than just the typeKey. also the typeId, parenTypeId and sortOrder are different.

    here's my update (doesn't accept "code", so using pre). Make sure to replace YOURUUIDHERE with your UUID for the gear.

    jQuery.getJSON(
        '/modern/proxy/activitylist-service/activities/search/activities?limit=10000',
        function(act_list)
        {
            console.log(act_list.length)
            act_list.forEach(
            function(act)
                {
                    if (act['activityType']['typeKey']=="uncategorized") {
                        console.log(act)
                        
                        fetch('/modern/proxy/activity-service/activity/' + act['activityId'],
                        {
                            'headers': { 'Content-Type': 'application/json', 'NK': 'NT', 'X-HTTP-Method-Override': 'PUT' },
                            // running:
                            'body': '{"activityName":"'+act['activityName']+' Run","activityTypeDTO":{"typeId":6,"typeKey":"running","parentTypeId":1,"sortOrder":6},"activityId":' + act['activityId'] + '}',
                            'method': 'POST'
                        });
                        
                        
                        // link gear
                        fetch('/modern/proxy/gear-service/gear/link/YOURUUIDHERE/activity/' + act['activityId'],
                        {
                            'headers': { 'Content-Type': 'application/json', 'nk': 'NT', 'X-HTTP-Method-Override': 'PUT' },
                            'method': 'POST'
                        });
                    }
                }
            );
        }
    );
  • This is a great post, it saved me a lot of time :-)
    By any chance do you know how a gear could be removed?  I ended up with more than one gear per activity in some activities

  • yes, it is similar; where it says "link" in the url (i.e. /modern/proxy/gear-service/gear/link/YOURUUIDHERE/activity/) make that "unlink" and it removes the link of the gear (identified by UUID) to the activity (identified by activityID).

  • Hello, what a great post is this ! Thanks a lot !

    Can you help me out on an extra on this ?
    I would love to change the gear of all bicycle activities from 2019 on with a distance below 10km to my "citybike" ;-)   Thinking

    Thanks !


    It's a pity that Garmin still can't connect a default gear to a specific activity...commuting bike, a race bike, a mountainbike... 

  • This worked great! Now all my old Strava imports are showing up in Reports. Thanks so much! I had to remove the + " Run" command however...

  • Hey there - I'd also like to batch change activities imported from another service (approx 600 activities). I'm wondering if you could provide more detailed steps, as I'm not a computer/web programmer and can't seem to work it out. I can view the console in Firefox on the activities page - but I can't find anything about Java Script! Any help to get from the initial console view to being able to enter the script would be much appreciated