Upload TCX to Strava - Bad Request

447 views
Skip to first unread message

Michael Phillips

unread,
Oct 10, 2014, 5:31:56 PM10/10/14
to strav...@googlegroups.com
Hi, there.

I'm having trouble uploading a TCX file to Strava.  Here is my Node.js code:

var file = request.get(tcxEndpointUrl);
        
  headers: {
    Authorization: 'Bearer ' + strava.token
  },
  formData: {
    data_type: 'tcx',
    file: file
  }
}, function() {
  console.log('post result', arguments);
});

The resulting body is:

{"message":"Bad Request","errors":[{"resource":"Upload","field":"data","code":"empty"}]}

Can anyone point me in the right direction here?  First, I don't see a `data` field outlined in the docs, so I'm not sure what that means.  Second, the `@` sign in front of the file name, I'm not sure what that's about.  I feel like the issue lies in the way I'm posting the file to the Strava API.

Thanks in advance for any help you can offer.


Michael

Paul Mach

unread,
Oct 10, 2014, 6:15:16 PM10/10/14
to Michael Phillips, strava-api
The file data you're sending is empty, probably because you're not issuing a proper multipart post.  In this case you may try "data: file" to send it along as a regular post. That should work, assuming the file variable isn't actually empty. 

The @ symbol in the sample curl command is a curl thing to send the contents of the file and not just it's name. 

Dr. Paul Mach
STRAVA

--
You received this message because you are subscribed to the Google Groups "Strava API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to strava-api+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Phillips

unread,
Oct 10, 2014, 6:41:47 PM10/10/14
to strav...@googlegroups.com, mlp.br...@gmail.com
Thanks for the help, Dr. Mach.

Changing the key from `file` to `data` doesn't seem to make a difference.  I'm also not entirely sure what you mean about my request not issuing a proper multipart post.  Here is a gist of the output of the httpResponse from the POST.  Maybe this can help illuminate the issue:

Paul Mach

unread,
Oct 10, 2014, 6:44:34 PM10/10/14
to Michael Phillips, strava-api
I don't know, but content length here looks suspicious. 

_header: 'POST /api/v3/uploads HTTP/1.1\r\nAuthorization: Bearer {access_token}\r\nContent-Type: multipart/form-data\r\nhost: www.strava.com\r\ncontent-length: 0\r\nConnection: keep-alive\r\n\r\n',


Dr. Paul Mach
STRAVA

Marek P

unread,
May 20, 2019, 3:48:06 PM5/20/19
to Strava API
Hi,
I had the same Problem, here is a working example with Python

https://gist.github.com/paulsoning/a376186560cbaf1bdc68701fce7e3d47

Br,
Marek Paulson
Reply all
Reply to author
Forward
0 new messages