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'
{
"collectionType": "sleep",
"ownerId": "USERID",
"ownerType": "user",
"subscriberId": "dev",
"subscriptionId": "dev001"
}
{
"collectionType": "activities",
"ownerId": "USERID",
"ownerType": "user",
"subscriberId": "dev",
"subscriptionId": "dev001"
}
Answered! Go to the Best Answer.
I see the problem @Gordon-C
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
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
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
Best AnswerWhen 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 AnswerThe 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.jsonResponse:
{
"apiSubscriptions": [
{
"collectionType": "activities",
"ownerId": "USERID",
"ownerType": "user",
"subscriberId": "dev",
"subscriptionId": "dev001"
}
]
}I hope this information is helpful for you to check.
Best Answer