I've done this many, many times in the past, so it's not a problem with finding the gear icon.
When I download a GPX or TCX, I get 400 Bad request.
Here's an example URL giving me the error:
https://connect.garmin.com/modern/proxy/download-service/export/gpx/activity/5375237499
I got to that page from here: https://connect.garmin.com/modern/activity/5375237499
by clicking the gear icon and choosing export to GPX