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

Can't Subscribe User

Hello,

 

I'm developing a web application that uses the Fitbit subscription API. We have around ~150 users that we've successfully subscribed to, but we're having trouble with one particular user. We have valid refresh/access tokens for them, and are able to pull their data manually via the web API, but we can't seem to create a subscription to their activity data.

 

* User has authorized us to access: profile, activity, settings

* Subscription id we're trying to create is '132-activities'

* Trying to subscribe to this user's activity data results in HTTP 409 (Conflict) with the following body: 

{"collectionType":"activities","ownerId":"<<fitbit_user_id>>","ownerType":"user","subscriberId":"<<our_subscriber_id>>","subscriptionId":"132-activities"}  .... I've verified that the ownerId matches up to the correct user in our database, and that the subscriber id is correct.

* Trying to DELETE subscription '132-activities' results in HTTP 404 (Not Found)

* Listing subscriptions via https://api.fitbit.com/1/user/-/apiSubscriptions.json (i.e., not specifying a collection) results in HTTP 403 (Forbidden) with the following message: "

This application does not have permission to access nutrition, sleep, weight data. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."
* If we specify the 'activities' collection, we get a response with an empty array of apiSubscriptions

* We have only one subscription end-point for this application, and we are using the X-Fitbit-Subscriber-Id header

* We're using django-fitbit/python-fitbit

 

In summary, we get HTTP Conflict when we try to subscribe to this user using subscription id of '132-activities'. There doesn't seem to be an existing subscription for our subscriber id with this subscription id because we get a 404 when we try to delete it. There doesn't seem to be any existing subscriptions for our subscriber id to this user because the only collection we're authorized to subscribe to is activities, and querying the list-subscription-activities endpoint returns an empty array.

 

Best Answer
0 Votes
1 REPLY 1

thesignalcenter wrote:

* User has authorized us to access: profile, activity, settings

* Subscription id we're trying to create is '132-activities'

* Trying to subscribe to this user's activity data results in HTTP 409 (Conflict) with the following body: 

{"collectionType":"activities","ownerId":"<<fitbit_user_id>>","ownerType":"user","subscriberId":"<<our_subscriber_id>>","subscriptionId":"132-activities"}  .... I've verified that the ownerId matches up to the correct user in our database, and that the subscriber id is correct.


@thesignalcenter From our docs:

 

About Conflicts: A single user can only subscribe to the same stream once. If a conflict arises trying to add a subscription, the server will respond with an HTTP 409 Conflict. It will still return the same response elements, but in this case, the body will tell you that the subscription already exists so that corrective action must be taken.

 

Since you're getting a 409, the subscription has to already exist somewhere but isn't necessarily named "132-activities".

 


thesignalcenter wrote:

* Trying to DELETE subscription '132-activities' results in HTTP 404 (Not Found)


>> This is expected since subscription "132-activities" was never created.

 


@thesignalcenter wrote:

 

* Listing subscriptions via https://api.fitbit.com/1/user/-/apiSubscriptions.json (i.e., not specifying a collection) results in HTTP 403 (Forbidden) with the following message: "

This application does not have permission to access nutrition, sleep, weight data. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."


>> Expected response for that endpoint because the user did not grant access to all scopes.

 

If you PM me your clientID, I can take a closer look.

 

 

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes