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

Unable to create subscription for other collection-path except activities

ANSWERED

I am making the request to creates a subscription to notify the application when a user has new data available. Followed by the docs here here but the response only pointed to activities collection-path. Do I miss anything? 

 

curl --location --request POST 'https://api.fitbit.com/1/user/-/sleep/apiSubscriptions/dev001.json' \
--header 'X-Fitbit-Subscriber-Id: dev' \
--header 'Authorization: Bearer ACCESS_TOKEN'

 

 
Expected output:
 

 

{
    "collectionType": "sleep",
    "ownerId": "USERID",
    "ownerType": "user",
    "subscriberId": "dev",
    "subscriptionId": "dev001"
}

 

 
Actual output:
 

 

{
    "collectionType": "activities",
    "ownerId": "USERID",
    "ownerType": "user",
    "subscriberId": "dev",
    "subscriptionId": "dev001"
}

 

 
 
Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

I see the problem @GordonFitbit 

I use dev001 to create activities subscription before. 

So I tried to use another subscription ID to create for sleep, eg USERID-sleep, and it worked!

 

View best answer in original post

Best Answer
0 Votes
4 REPLIES 4

Hi @jimmyhoang 

 

When you try to create the subscription for sleep, what is the http status code returned along with the "activity" response?   And, did you create the subscription for activity using the subscriptionId "dev001"?

 

Gordon

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

When you try to create the subscription for sleep, what is the http status code returned along with the "activity" response? 409

 

And, did you create the subscription for activity using the subscriptionId "dev001"? Yes, I did.

I made a call for activities using url:

 

https://api.fitbit.com/1/user/-/activities/apiSubscriptions/dev001.json

 

 And then received the same response like above:

{
    "collectionType": "activities",
    "ownerId": "USERID",
    "ownerType": "user",
    "subscriberId": "dev",
    "subscriptionId": "dev001"
}

 

Best Answer
0 Votes

The docs indicates that 409 code means "Returned if the given user is already subscribed to this stream using a different subscription ID, OR if the given subscription ID is already used to identify a subscription to a different stream."

 

So I made a call to Get Subscription List:

https://api.fitbit.com/1/user/-/apiSubscriptions.json

Response:

{
    "apiSubscriptions": [
        {
            "collectionType": "activities",
            "ownerId": "USERID",
            "ownerType": "user",
            "subscriberId": "dev",
            "subscriptionId": "dev001"
        }
    ]
}

I hope this information is helpful for you to check. 

Best Answer
0 Votes

I see the problem @GordonFitbit 

I use dev001 to create activities subscription before. 

So I tried to use another subscription ID to create for sleep, eg USERID-sleep, and it worked!

 

Best Answer
0 Votes