02-17-2022 01:13
02-17-2022 01:13
This document states that the URL to create a subscription for the user is as follows ->
https://api.fitbit.com/1/user/-/apiSubscriptions/320.json
But using this URL, I get 400 Bad Request and response as given below:
02-23-2022 12:55
02-23-2022 12:55
As the error states, you need to provide the subscriber ID when calling the create subscription endpoint. There is a request header you may use for specifying the value. For details, see https://dev.fitbit.com/build/reference/web-api/subscription/create-subscription/.
Gordon
03-02-2022 04:14
03-02-2022 04:14
Hello GordonFitbit,
Thanks for your response! Create Subscription API now works for me. FitbitSubscriberId was optional, It worked even without that. Hence, I skipped it while creating subscriptions.
For user 9TQKY5, I created subscriptions for activities, sleep & body collection_paths.
And I have registered https://778b-103-120-252-70.ngrok.io/integration/fitbit/webhook/notifications endpoint to recieve WebHook notifications.
https is enabled on this URL using ngrok.
But when I added sleep logs for this user on the fitbit application, I was not able to receive the Fitbit Notification.
I have coded in java to recieve the same. and Following is the code snippet of method signature receiving fitbit notifications.
@PostMapping(value = "/notifications", consumes = { MediaType.MULTIPART_FORM_DATA_VALUE })
public ResponseEntity<APIResponse> receiveDataUpdateNotification(
@RequestPart("updates") List<FitbitNotification> fitbitNotifications, HttpServletRequest request) {
//Function body goes here..
}
Kindly assist me with the correct approach to receive Fitbit Notifications for the subscriber user.
There is one more query I was curious to know about ->
Lets say I have two applications registered with same subscriber id as 1234. ( I am assuming subscriber id is the one above the URL https://778b-103-120-252-70.ngrok.io/integration/fitbit/webhook/notifications in the screenshot). Correct me If I am wrong.
how does Fitbit understand, who has subscribed since create subscription API only accepts the subscription id as the mandatory URI param, rest are optional and we have two apps with same subscriber ids.
Kindly confirm if the subscriber id concept is right as per my understanding, Its the number which we put while creating subscribers.
03-03-2022 09:50
03-03-2022 09:50
Would you please private message me the client ID of your application? I'll see if I can determine if notifications are being sent to your subscriber.
Regarding your question about 2 applications having the same subscriber, I don't think that is a problem. We have your subscriber URL stored in our database and send the notifications to the URL. As long as the subscriber is publicly accessible, then we should not have a problem sending you the notification. It'll be up to your subscriber to receive the notification and process it accordingly.
Gordon