Skip to main content

Hello Zapier Community,

I'm currently working on automating an API request to Strava for uploading activity data (a “.tcx” file). However, I’m encountering issues with setting up the multipart/form-data for a file upload through Zapier's API Request action.

Here’s the example curl request provided by Strava for reference (https://developers.strava.com/docs/uploads/):

Example Request 

For file, the @ symbol means to use the content of the file at the file path we specify. Otherwise, we are just giving it a string that’s the file name, not the content.

$ curl -X POST https://www.strava.com/api/v3/uploads \
-H "Authorization: Bearer abcd123abcd123abcd123abcd123" \
-F activity_type="walk" \
-F name="Test Walk" \
-F description="Test description" \
-F trainer=0 \
-F commute=0 \
-F data_type="gpx" \
-F external_id="98765" \
-F file=@/Users/serenawilliams/Downloads/walk.gpx

 

This is what I've done so far in Zapier:

  1. I set the HTTP method to POST and the URL to https://www.strava.com/api/v3/uploads.
  2. Authentication headers are included automatically.
  3. I’ve entered the necessary parameters such as activity_type, name, description, etc., in the Body field in JSON format.

    in the previous step I do find the File successfully : 

     
  4. I am confused about where to place the actual .tcx file. The Strava API requires the file content to be part of the request, not just a URL to the file.

The error I keep encountering is Raw request failed. undefined: Bad Request, which indicates a problem with how I'm structuring the request 😒

Can someone guide me on how to properly structure the file upload for multipart/form-data using Zapier's API Request action? If the standard action cannot support multipart/form-data, is there a workaround, possibly using "Code by Zapier" to properly format and send the request?

I’d greatly appreciate any examples or insights into best practices for handling file uploads with Zapier's automation tools.

Thank you in advance for your help!

Hi there @Johannes267👋

Hmm, I’m not super familiar with Strava’s API but seems like it’s expecting to receive a publicly-accessible link to the file rather than the file object itself. 

In the API Request (Strava) action can you try selecting the Alternate Link field from the Google Drive step instead of the File field? 

Depending on the permissions for the file in your Google Drive you may need to add an Add File Sharing Preference (Google Drive) action ahead of the Strava action step in order to allow anyone with a link to the file direct access to view it. That would allow Strava access to download the file so it can then import it.

Can you give the above a try and let us know if that works any better?


Hi, 
Thanks for your answer !
I can confirm that my file is publicly accessible (actually both the folder and the file itself are “public”). 

So I tried with the “alternate link” but I have the same error : 
 


Thanks for any additional suggestions :-)


Thanks for confirming that @Johannes267.

I wonder if there’s a bug with the API Request action that’s causing it to not send over the file correctly. Can you try recreating that POST request in a Webhooks action to see if it’s able to upload the file? With Webhooks actions there’s a File field so I’d suggest using that to see if it will accept the tcx file then. See our Send webhooks in Zaps guide for more details.

Please keep us updated on how you get on with that, keen to help get this sorted! 🙂