I'm attempting to upload an Activity to the /uploads endpoint. (from Java) I've used the Garmin SDK to generate a Fit stream, and attempting to post. (The OAuth2 workflow is working fine, I've acquired an access token). First, the error:
{"message":"Bad Request","errors":[{"resource":"Upload","field":"data","code":"empty"}]}
What I don't understand is that according to the API docs there is no "data" field.
The code (using Jakarta HTTP Client)
InputStream fitStream = buildFitStream(user, save);
try (FormDataMultiPart form = new FormDataMultiPart();
MultiPart entity = form.field("name", "Name")
.field("description", "Description")
.field("trainer", "true")
.field("externalId", metaData.workoutID())
.field("data_type", "fit")
.bodyPart(new StreamDataBodyPart("file", fitStream, "row.fit"))) {
return request.post(Entity.entity(entity, entity.getMediaType()), UploadResponse.class);
Here is some debugging output from the request:
1 > POST https://www.strava.com/api/v3/uploads
1 > Accept: application/json,text/plain
1 > Authorization: [redacted]
1 > Content-Type: multipart/form-data
--Boundary_3_592165230_1714169487959
Content-Type: text/plain
Content-Disposition: form-data; name="name"
Name
--Boundary_3_592165230_1714169487959
Content-Type: text/plain
Content-Disposition: form-data; name="description"
Description
--Boundary_3_592165230_1714169487959
Content-Type: text/plain
Content-Disposition: form-data; name="trainer"
true
--Boundary_3_592165230_1714169487959
Content-Type: text/plain
Content-Disposition: form-data; name="externalId"
46af4101-6b81-4583-9849-05c9c3c4f8f4
--Boundary_3_592165230_1714169487959
Content-Type: text/plain
Content-Disposition: form-data; name="data_type"
fit
--Boundary_3_592165230_1714169487959
Content-Type: application/octet-stream
Content-Disposition: form-data; filename="row.fit"; name="file"
� z 8@ �� ���� �
--Boundary_3_592165230_1714169487959--
INFO 2024-04-26 22:11:28,086] jerseyClientDebug: 1 * Client response received on thread pool-3-thread-21
1 < 400
1 < Cache-Control: no-cache
1 < Connection: keep-alive
1 < Content-Type: application/json; charset=utf-8
1 < Date: Fri, 26 Apr 2024 22:11:29 GMT
1 < Referrer-Policy: strict-origin-when-cross-origin
1 < Status: 400 Bad Request
1 < Transfer-Encoding: chunked
1 < Vary: Accept, Origin
1 < Via: 1.1 linkerd, 1.1 linkerd, 1.1 e77661e211afe9242e85e573f12d5534.cloudfront.net (CloudFront)
1 < X-Cache: Error from cloudfront
1 < X-Content-Type-Options: nosniff
1 < X-Download-Options: noopen
1 < X-Frame-Options: DENY
1 < X-Permitted-Cross-Domain-Policies: none
1 < X-RateLimit-Limit: 200,2000
1 < X-RateLimit-Usage: 2,16
1 < X-ReadRateLimit-Limit: 100,1000
1 < X-ReadRateLimit-Usage: ,
1 < X-Request-Id: 15206174-8808-4dac-8535-1a39adc1df9d
1 < X-XSS-Protection: 1; mode=block
{"message":"Bad Request","errors":q{"resource":"Upload","field":"data","code":"empty"}]}