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

Unable to call Create Subscription API

https://dev.fitbit.com/build/reference/web-api/developer-guide/using-subscriptions/#Creating-a-Subsc...

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:

{
    "errors": [
        {
            "errorType""validation",
            "fieldName""subscriberId",
            "message""Invalid parameter subscriberId: null"
        }
    ]
}
 
Kindly assist with the URL to be used to create subscriptions and what should be the sample response.
Best Answer
0 Votes
3 REPLIES 3

Hi @SujeetShettyAdp 

 

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

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

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. 

Subscriber_details.png

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. 

 

Best Answer
0 Votes

Hi @SujeetShettyAdp 

 

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

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