Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Issue logging activity

First off I have to say the documentation is a bit dissapointing, having a full example of the http request examples would help a ton. Second the documentation for logging activities doesn't work for me

 

This is the payload copy pasted from here https://dev.fitbit.com/docs/activity/#activity-logging

{
    "activityLog":{
        "activityId":12030,
        "activityParentId":90009,
        "calories":197,
        "description":"5 mph (12 min/mile)",
        "distance":3.34,
        "duration":1800000,
        "isFavorite":false,
        "logId":132394,
        "name":"Running",
        "startTime":"12:20",
        "steps":2970
    }
}

 

 

Sending this request from fiddler results in a 400 with error message of 

{"errors":[{"errorType":"request","fieldName":"n/a","message":"Either \"activityId\" or \"activityName\" should be present"}]}

 

Clearly activityId is set. I've tried modifying this example for just adding a simple walk activity using all sorts of combinations of the walking activityId and activityName but I always get this error message.

 

In testing I also found out that sending bad json also results in this error message instead of informing the user that the json post payload isn't valid which would be very helpful.

 

Any ideas on what I'm doing wrong here?

 

Also could someone update the documentation to be correct? At least one required field (Date) for Logging an activity is different from the ones listed in the example.

 

(these parameters should correspond to the json blob above.

POST Parameters

activityIdoptional/requiredThis is the Activity ID of the activity, directory activity, or intensity level activity. If you pass directory activity id, Fitbit calculates and substitutes it with the corresponding intensity level activity id based on the specified distance and/or duration.
activityNameoptional/requiredCustom activity name. Either activityId or activityName must be provided.
manualCaloriesoptional/requiredCalories burned, specified manually. Required with activityName parameter, otherwise optional.
startTimerequiredActivity start time. Hours and minutes in the format HH:mm:ss.
durationMillisrequiredDuration in milliseconds.
daterequiredLog entry date; in the format yyyy-MM-dd.
distanceoptional/requiredDistance; required for logging directory activity. In the format X.XX and in the selected distanceUnit or in the unit system that corresponds to the Accept-Language header provided.
distanceUnitoptionalDistance measurement unit. Steps units are available only for "Walking" (activityId=90013) and "Running" (activityId=90009) directory activities and their intensity levels.

 

Thanks,

John

Best Answer
0 Votes
1 REPLY 1

@programit What's the request that you're making?

 

Here's an example:

https://api.fitbit.com/1/user/-/activities.json?activityId=90009&startTime=12%3A20&durationMillis=600000&date=today&distance=3.3 

 

Gives me this response:

HTTP/1.1 200 OK
Content-Language:
en
Cache-control:
no-cache, private
Fitbit-Rate-Limit-Limit:
150
Connection:
keep-alive
Server:
cloudflare-nginx
X-Frame-Options:
SAMEORIGIN
Date:
Tue, 10 Jan 2017 23:09:39 GMT
Transfer-Encoding:
chunked
Vary:
Accept-Encoding
Fitbit-Rate-Limit-Remaining:
150
CF-RAY:
31f3cc3ffabb239c-IAD
Fitbit-Rate-Limit-Reset:
3021
Content-Type:
application/json;charset=UTF-8

{
  "activityLog":  {
    "activityId": 90009,
    "activityParentId": 90009,
    "activityParentName": "Run",
    "calories": 201,
    "description": "Running - 5 mph (12 min/mile)",
    "distance": 3.299999,
    "duration": 600000,
    "hasStartTime": true,
    "isFavorite": false,
    "lastModified": "2017-01-10T23:04:38.585Z",
    "logId": 5510346712,
    "name": "Run",
    "startDate": "2017-01-10",
    "startTime": "12:20",
    "steps": 3737
  }
}

 

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer