cyberjunky / python-garminconnect

Python 3 API wrapper for Garmin Connect to get activity statistics
MIT License
964 stars 149 forks source link

Upload activity #88

Closed hishizuka closed 2 years ago

hishizuka commented 2 years ago

Hi, your project is so nice that it can authenticates reliably. Many other projects cannot.

I need the activity upload function. After many attempts, I found the workaround code.

additional_url = "proxy/upload-service/upload/.fit"
fit_file = "some_actifity.fit"
with open(fit_file, 'rb') as file:
    res = api.modern_rest_client.post(additional_url, {}, {}, file)

Can you implement above as an official function?

Thanks

cyberjunky commented 2 years ago

Any idea where I can get an example fit file to test with?

hishizuka commented 2 years ago

Thanks for your reply!

Assume you have a Garmin Connect account and have some activities.

  1. Open one of your activity and export the original from the settings in the upper right corner. This zip file conatinis the FIT file.

    スクリーンショット 2022-10-21 10 36 40
  2. Delete this activity. If same activity already exists, your code returns 409 Client Error。

  3. Upload this FIT file with the workaround.

cyberjunky commented 2 years ago

Hi @hishizuka Thank you, I have added it to Release 0.1.46, the call is called 'api.upload_fit_activity(activityfitfile)' you can find it in the example program as well.

hishizuka commented 2 years ago

Thanks so much! I'll get it into my program "pizero_bikecomputer".

cyberjunky commented 2 years ago

@hishizuka I have just replaced it in version 0.1.48 with the more generic api.upload_activity(file) which supports multiple filetypes.

cyberjunky commented 2 years ago

@hishizuka I have come across your project earlier, not knowing you use my code, very nice!!