Problem uploading an activity: 'not a file'

179 views
Skip to first unread message

chris fearnley

unread,
Feb 22, 2021, 3:00:27 PM2/22/21
to Strava API
Revised question with new information:
I'm attempting to upload an activity from my Android app. Having spent several days on working through the authorization process successfully, I am now stuck at the final hurdle. My POST for the upload returns a 400  error. The url is https://www.strava.com/api/v3/uploads?activity_type="ride"&name="testing"&description="fromWandrerHelper"&data_type="gpx"&file=@/storage/emulated/0/Android/data/com.quilkin.wandrerhelper/files/Download/temp.gpx
The resulting error is: {"message":"Bad Request","errors":{"resource":"Upload","field":"file","code":"not a file"}]} 
 The  GPX file itself has been tested separately, so it's the path that's not accepted. If I copy the file to my PC and use curl with the same url (with modified file path), the file uploads fine. But I can't use curl on the phone.
I've also tried using curl and postman on the PC with a file path to the file on the phone, but it appears that these apps can't use a path to a USB-connected phone.
So what's wrong with my file path? I've tried with and without quotation marks, (although the Strava developer examples suggest they aren't required).
The app has permission for reading the external files folder. It doesn't help, though, that android has several different ways of defining the path to files, especially since Android 8. I've tried all that I can find.

chris fearnley

unread,
Feb 23, 2021, 6:25:23 AM2/23/21
to Strava API
Solved this now and feel an idiot for such a  stupid error. The '@' symbol is, of course, used by curl - Android knows nothing about it. In curl it automatically and silently creates a multipart entity containing the file's data. In Android, afaics, there's no built-in library to do this and it takes over 200 lines of code to achieve it.
Reply all
Reply to author
Forward
0 new messages