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

POST activity with steps results in too many steps added

My goal is to manually update the step count via the Web API.

However, whenever I add steps (via POST ~user/-/activities.json), the dashboard in the app shows that I have added more steps than I actually did.

For example, when I start with 0 steps on the dashboard, manually POST 4000 steps,

 

Here is how I setup to post steps (in python):

url = "https://api.fitbit.com/1/user/-/activities.json"
now = datetime.now()
params = {
 "activityId": '90013', #walking activity
 "startTime": now.strftime("%H:%M:%S"),
 "durationMillis": 3600000,
 "date": now.strftime("%Y-%m-%d"),
 "distance": 4000,
 "distanceUnit": "steps"
}

This request works fine, no errors. When I query the Web API to see what was entered (using the "/activities/list.json" url) I get a list of activities that matches the activities, with accurate step count, that I posted.

 

However, the dashboard does not show 4000 steps, instead it updates to show 4,778 steps. Where did these extra steps come from? I thought it might be from the tracker, but there were 0 steps recorded when I posted the manual activity. Also, these extra steps (a seemingly random amount of them) are added every time I post a manual activity. (when I posted an activity with 6,000 steps, the dashboard updated to show 6,973 steps taken).

 

I'm not sure what's going on here. Could anyone shed some light on what is happening behind the scenes? How and Why are there extra steps being added to my POST request?

Best Answer
0 Votes
7 REPLIES 7

Hi @jaztech 

 

It's possible that between the time you manually entered the steps and checked the dashboard, your device paired with your mobile application or computer adding the steps you recorded on your tracker earlier in the day.

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hi @GordonFitbit, thank you for responding. The steps from the tracker are not the issue. I intentionally tested this at the beginning of the day when the tracker shows 0 steps and I did not move the tracker in between tests. What's more confusing is that sometimes logging a new activity will cause the total step count to *decrease* which confirms to me that its not an issue with the tracker, but something with the API.

 

So if I log two activities (by POSTing to /activities.json), and then I check the log, here's what I see as the json response. This is accurate and reflects the activity data that I logged.

[{'activityId': 90013, 'activityParentId': 90013, 'activityParentName': 'Walk', 'calories': 27, 'description': 'Walking less than 2 mph, strolling very slowly', 'distance': 0.179873, 'duration': 3600000, 'hasStartTime': True, 'isFavorite': False, 'lastModified': '2019-04-08T15:29:34.000Z', 'logId': 21114372435, 'name': 'Walk', 'startDate': '2019-04-08', 'startTime': '10:29', 'steps': 500}, {'activityId': 90013, 'activityParentId': 90013, 'activityParentName': 'Walk', 'calories': 0, 'description': 'Walking less than 2 mph, strolling very slowly', 'distance': 0.131743, 'duration': 3600000, 'hasStartTime': True, 'isFavorite': False, 'lastModified': '2019-04-08T15:44:04.000Z', 'logId': 21131821152, 'name': 'Walk', 'startDate': '2019-04-08', 'startTime': '10:44', 'steps': 200}]

 

But if I check my dashboard status (via /"~/activities/steps/date/<date>/1d.json"), then I see these strange values!

{'activities-steps': [{'dateTime': '2019-04-08', 'value': '320'}]}

 

Is there something I'm doing wrong with timing? Is it not possible to log two walking activities in the same day?  I'm really stumped...

 

The only way I can prevent this behavior so far is by deleting all the existing activities for the day, creating a new activity with the old activities' combined step count plus any new count, and logging a new activity with the new updated step count. 

Best Answer
0 Votes

Hi @jaztech ,

 

I think it would be best for me to see what your application is do in our logs.   Would you please reproduce the problem again, and private message me your client ID.   

 

Thanks!

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hi @jaztech ,

 

I figured out the problem.  The startTime parameter value should not contain the seconds.  In the documentation, we state 

 

startTime required Activity start time. Hours and minutes in the format HH:mm:ss.

 

This parameter only wants the hours and minutes, not the seconds.  I've tested having a startTime in the format hh:mm and hh:mm:00 and they both seem to work.  Because the doc is suggesting you provide seconds, consider using the format hh:mm:00.   I'll update the documentation to clarify this requirement.

 

Please test removing the seconds or setting the seconds to zero (00) and see if that corrects the step count.  It did for me.

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hi GordonFitbit,

 

I have changed the parameter to use only H:M as you suggested, however, the issue persists. I can add the expected number of steps via logged activity, and a query of the logged activities shows that this number of steps has been logged. However, this number of steps does not show up on the user's dashboard.

The first time I log a new set of steps for the day, the proper value shows up. However any subsequent logs result in basically garbage values appearing on the dashboard.

 

 

 

Best Answer
0 Votes

Hi @jaztech 

 

Would you please private message me your client ID and the user ID in question.  I'll look through our logs and investigate further.

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hi @jaztech 

 

Thank you for sending me the additional information.  This is what I see regarding the 3 walking activities you have recorded

 

Activity 1

Steps: 2000

Start Time: 10:30

Duration: 60 minutes

 

Activity 2

Steps: 5000

Start Time: 10:32

Duration: 60 minutes

 

Activity 3

Steps: 10000

Start Time: 10:35

Duration: 60 minutes

 

What you have is 3 walking activities that over lap each other.  I'm assuming what we are doing is spreading out the number of steps for each activity for each hour and removing any duplicate data.   Instead of 17000 steps across 3 hours, you're seeing 10315 steps across 1 hour 5 minutes.  I tested this out with those numbers and I can reproduce 10,315 steps showing up in my dashboard like you did.

 

However, if I record each 60 minute activity with the appropriate start times of 10:30, 11:30 and 12:30, I do see 17,000 steps in my dashboard.

 

Give this a try and let us know what you find out.

 

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes