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

Subscription messages

Two neophyte question about what we are passed by the subscriptions api if I may...

 

Question 1: In the JSON returned [e.g. below], does the date refer to the date the activity was created on the wristband, or the date it was synced with the Fitbit Account?

 

If multiple activities are synced at one time, but created over several days - will I get one of these subscription notices in total for that streamtype&user, with the date being the date of the earliest activity I have just synced, or will I get separate sub-blocks of JSON, one for each activity - but passed in a single notification event? 

 

This is what I am getting back, I am subscribed as "all". Ownerid xxd out for privacy...

 

{"collectionType":"activities","date":"2020-03-16","ownerId":"xxxxxx","ownerType":"user","subscriptionId":"all-xxxxxx"}

 

Question 2: I pass back an "HTTP/1.1 204 No Content" header. In the "subscriber" part of the "manage my app" interface, I get a row in the "details" area table that shows a response code of 204, on a green background. HOWEVER - the subscription server KEEPS contacting me, to pass the above JSON. I had assumed that when I sent it the 204 header, it would stop. How do I make it stop? There are 67 attempts in the "details" listing, most of them in green (a few are white, where I was having problems with grabbing the input), but on the main app page it says

 
stats
100%
Delivered: 2 Failed: 0

Which is a bit weird... What does the "2" refer to? I have synced multiple activities from wristband to Fitbit Account over the course of the day...
 
Thanks in advance.
 
Nick
 
[A final point for anyone using nginx and php7 - you may have to use
file_get_contents("php://input") rather than $_POST to get the subscription message.] 
 ]
 
Best Answer
0 Votes
1 REPLY 1

Hi @nickmay 

 

Question 1:   The date in the webhook notification is the date the activity occurred.  We try to combine the notifications as much as possible.   You should get a notification for each day the activity occurred.   

 

Question 2: Your application needs to respond to each webhook notification with a 204.   If we fail to get responses from your subscriber, then we might assume your subscriber is not being used anymore and disable it.   In the subscriber settings of dev.fitbit.com, the green boxes represent successful messages that were sent and received.  

 

If you're constantly receiving webhook notifications, it could mean the device is connected to the mobile app with auto-sync enabled.  The device syncs with the mobile app automatically every 15 minutes.  Whenever new activity data is received, a webhook notification is sent.   Even if you're not moving, a body burns calories and received new heart rate data through the activity endpoint.  I suspect this is why you're receiving webhook notifications.

 

Regarding the "2", I'm not sure what you're referring to.  Would you please provide me with your client ID?

 

Thanks!

Gordon

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