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

Make Request with PostMan to get Heartrate

ANSWERED

Hello,

 

I'm trying to make a simple request on the API to get back heartrate scope.

 

I red API documentations and many subjects and the forum but i sill do not understand how to do it.

 

here where i am:

 

  1. Set in API an new app to be able to get the require information to get create an refresh a token
  2. With postman
    1. i set url request: get -> https://api.fitbit.com/1/user/-/profile.json
    2. In authorization : choose OAuth2 , Manually Get New Access Token ( left orange button -> get New Access oken) , and fill the required informations 
      1. Token Name
      2. Auth URL
      3. Access Token URL
      4. Client ID
      5. Client secret
      6. Scope: heartrate
      7. Grand type: Authorization Code
      8. Then click to add tokenin the header
    3. In header:
      1. Content-type: application/x-www-form-urlencoded
      2. Authorization : bearer ...(automatically filled by the step 1.2.8)

When i send the request i received the following message

 

{"errors":[{"errorType":"insufficient_scope","message":"This application does not have permission to access profile data. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":false}

 

i don't get it , i already gave this information in the step 2.2.6.

 

Any ideas?

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

@dsalerne You're using your client ID when you should be using your user ID.

 

https://api.fitbit.com/1/user/2287Q3/activities/heart/date/today/1d/1sec.json

 

2287Q3 - this is your client ID.

See my post on how to get your user ID and use that instead.

 


@AndrewFitbit wrote:


@dsalerne  Your userId is not on that page, it's at the end of the URL when you click "View Profile" from your dashboard settings (you can also navigate there by clicking your profile image at: https://www.fitbit.com)

 


 

Andrew | Community Moderator, Fitbit

What motivates you?

View best answer in original post

Best Answer
0 Votes
11 REPLIES 11

@dsalerne The call you're making is to access profile data, not heart rate. You're only granting the heart rate scope, so you don't have permission to access anything else other than heart rate. This is why you get an "insufficient_scope" error when you make this call: https://api.fitbit.com/1/user/-/profile.json

 

The heart rate endpoints are listed in our API docs if you're trying to get heart rate data.

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes

 

Hello,

 

My computer crashed and i lost whole my postman config. 

I set like before, now with the good adress to get.

I get the token with authorization page, i give the authorization but when i try to request with this

 

https://api.fitbit.com/1/user/[MYUSERID]/activities/heart/date/today/1d/1sec.json

 

i received this message:

 

{"errors":[{"errorType":"insufficient_permissions","message":"API client is not authorized by the resource owner to access the resource requested. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":false}

Best Answer
0 Votes

@dsalerne When you auth your app, you need to grant access to the heart rate scope to be able to access heart rate data.

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes

Hello,

 

It seems to me i do so.

 

After setting app in devfitbit account and do my first request to get token i have the authorization popup with the description my application wants to access data on Hearrate ( selected). I select "Accept" but still have the error.

 

Is there an other step?

Best Answer
0 Votes

@dsalerne wrote:

 

https://api.fitbit.com/1/user/[MYUSERID]/activities/heart/date/today/1d/1sec.json

 


@dsalerne Are you substituting [MYUSERID] with "-" or with an actual user id? Because if you're inserting a user id of a user that did not auth your app, then that would be another reason why you would see the following error:

 


@dsalerne wrote:

 

{"errors":[{"errorType":"insufficient_permissions","message":"API client is not authorized by the resource owner to access the resource requested. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":false}


 

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes

Hello,

 

I'm submitting with my userId. 

 

The one i got from "application | Registered"

Best Answer
0 Votes

Hello,

 

i still have the issue.

 

Any idea?

Best Answer
0 Votes

dsalerne wrote:

I'm submitting with my userId. 

The one i got from "application | Registered"


@dsalerne  Your userId is not on that page, it's at the end of the URL when you click "View Profile" from your dashboard settings (you can also navigate there by clicking your profile image at: https://www.fitbit.com)

 

Can you show me the actual request you're trying to make, including what you're using for userId?

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes

Hello,

 

I'm trying to request with this:

https://api.fitbit.com/1/user/2287Q3/activities/heart/date/today/1d/1sec.json

 

to be able the same data as your example

https://api.fitbit.com/1/user/-/activities/heart/date/today/1d/1sec.json{"activities-heart":[{"dateTime":"2017-01-16","value":{"customHeartRateZones":[],"heartRateZones":[{"max":93,"min":30,"name":"Out of Range"},{"max":130,"min":93,"name":"Fat Burn"},{"max":158,"min":130,"name":"Cardio"},{"max":220,"min":158,"name":"Peak"}]}}]}

 

 

Here are my setting concerning the request token

setting_postman_fitbit.jpg

Best Answer
0 Votes

@dsalerne You're using your client ID when you should be using your user ID.

 

https://api.fitbit.com/1/user/2287Q3/activities/heart/date/today/1d/1sec.json

 

2287Q3 - this is your client ID.

See my post on how to get your user ID and use that instead.

 


@AndrewFitbit wrote:


@dsalerne  Your userId is not on that page, it's at the end of the URL when you click "View Profile" from your dashboard settings (you can also navigate there by clicking your profile image at: https://www.fitbit.com)

 


 

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes

Hi, I'm having trouble using someone else's user ID, can I ask you for advice?

Best Answer
0 Votes