Hello,
is there any way to bulk update my old activities with new segments?
Hello,
is there any way to bulk update my old activities with new segments?
It used to be automatic, currently only manually or by script.
jQuery.ajaxSetup({headers:{ 'DI-Backend':'connectapi.garmin.com', 'Authorization':'Bearer '+JSON.parse(localStorage.token).access_token }})
t=0 jQuery.getJSON( 'https://connect.garmin.com/activitylist-service/activities/search/activities?limit=1', all => all.forEach(async a => { await new Promise(s=>setTimeout(s,t+=20000)) jQuery.ajax({ method: 'PUT', url: 'https://connect.garmin.com/activity-service/activity/segment/' + a.activityId}) console.log(a.activityId) } ) )
Change a.activityId in the second URL to some activity, to be sure which will be used, run it and wait some minutes, then check if that activity's segments got refreshed.
Or open Network tab and check if request worked (green status).
If still no new segment, then compare with manually pressing Match Segments on that activity - sometimes it just won't match some segments.
Yes, violet status, so didn't work. Don't see why though. Tested with one running and one cycling activities and it worked.
Maybe compare requests, manual from the button and from the script. Open an activity and try both, then on the Network tab - right click on each request and Copy as Fetch and compare if something is missing.
Some headers are optional, but you can try adding few more, or to be sure you can replace jQuery.ajax({...}) with full fetch copied from a manual request, or run only that fetch, without the loop, to check if it works for single activity.
Yes, there are some differences:
Button Match New Segments was pressed, but Answer is "Too many activity segment match requests have been submitted for this user.".
Same answer I got from the Script.
It's looks like, that Garmin has some protection not to run more requests for some time.
Only few headers are missing: user-agent, body, accept, content-type, but those are rather optional here and should work the same.
But as the button also doesn't work, then it's the limit. Some time ago they removed auto match of all segments for all activities, and it looks they even added the limit to the manual match button to make sure the Segments take little server's time.
So you can only run it by parts using filters like dates if it's a long time-span limit with reasonable count, or if long and very small then clicking manually is easier.
But try adding more wait time between requests, could be a short time-span limit (I edited to 20000 in the script now).