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:
- I set the HTTP method to POST and the URL to
https://www.strava.com/api/v3/uploads
. - Authentication headers are included automatically.
- I’ve entered the necessary parameters such as
activity_type
,name
,description
, etc., in theBody
field in JSON format.
in the previous step I do find the File successfully :
- 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!