Upload an activity file
const url = 'http://localhost:8080/api/v1/activity/upload';const form = new FormData();form.append('file', 'file');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:8080/api/v1/activity/upload \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: multipart/form-data' \ --form file=@fileQueues a .fit, .tcx or .gpx file for import.
The upload is asynchronous: a success is 202 Accepted, not 200 OK.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
The activity file. Must be named *.fit, *.tcx or *.gpx.
Responses
Section titled “Responses”The file was queued for import.
object
Examples
{ "status": "queued", "message": "File queued for import."}No usable file part was sent.
Every error uses this shape.
object
A stable, machine readable code.
Examples
{ "error": "missing_file", "message": "A \"file\" part is required."}The Authorization header was missing, malformed, or did not match the configured key.
Every error uses this shape.
object
A stable, machine readable code.
Examples
{ "error": "invalid_token", "message": "A valid API token is required. Send it in the Authorization header as a Bearer token."}Headers
Section titled “Headers”This instance runs with IMPORT_MODE=stravaApi, so it cannot accept uploaded files.
Every error uses this shape.
object
A stable, machine readable code.
Examples
{ "error": "import_mode_not_files", "message": "Activity files can only be uploaded when running in file import mode."}The file is larger than upload_max_filesize, or the whole request is larger than post_max_size.
Every error uses this shape.
object
A stable, machine readable code.
Examples
{ "error": "file_too_large", "message": "The uploaded file is too large."}The body was not multipart/form-data.
Every error uses this shape.
object
A stable, machine readable code.
Examples
{ "error": "unsupported_media_type", "message": "Send the file as multipart/form-data."}The filename is unusable. Either the extension is not one of fit, tcx or gpx, or the name itself contains control characters or invalid UTF-8.
Every error uses this shape.
object
A stable, machine readable code.
Examples
{ "error": "unsupported_file_type", "message": "The file type is not supported."}The upload could not be stored.
Every error uses this shape.
object
A stable, machine readable code.
Examples
{ "error": "internal_error", "message": "The upload could not be stored."}