simonbromberg / googlefitbit

Google Sheets scripts for Fitbit data download (not actively maintained, feel free to submit a PR tho)
167 stars 49 forks source link

dataset from undefined #31

Open choce001 opened 6 years ago

choce001 commented 6 years ago

Hello, I tried intraday and interday and they worked very weel but whenI run the intraday_all I got this message "TypeError: Unable to read dataset property from undefined" any idea ? Thanks by advance

rileym94 commented 6 years ago

I'm running into this same issue.

simonbromberg commented 6 years ago

Have you requested intraday data access from Fitbit?

Although if you're only using your own personal account that may not matter.

rileym94 commented 6 years ago

According to fitbit, as a personal app, we don't need to. https://community.fitbit.com/t5/Web-API-Development/Intraday-data-now-immediately-available-to-personal-apps/td-p/1014524

simonbromberg commented 6 years ago

Have you tried the other intraday script?

rileym94 commented 6 years ago

I believe I tried them both, I will retry both of them now just to make sure.

rileym94 commented 6 years ago

Tried again quickly at work, screwed something up where I got 'OAuth2 is not defined'

I'll try again later this afternoon. Gotta prep for a meeting...

simonbromberg commented 6 years ago

Also, are you sure there's data during the time period you're testing?

rileym94 commented 6 years ago

Yes. I've pulled data with another app.

gravinamike commented 6 years ago

I'm running into just the same problem! I'll break down some of the troubleshooting I've done so far on intraday_all.gs:

  1. Line 294: var row = o[intradaysfield]["dataset"]; The variable o refers to a .json dictionary which is derived from the result of the fetch on line 280, and the key intradaysfield is set up as the string "activities-heart-intraday".

  2. The fetch on line 280 is returning a result with only one top-level key, "activities-heart". That looks like the reason for that undefined error; there's no "activities-heart-intraday" key to access.

I'm guessing that this means the account is not delivering intraday data for some reason. It's a bit puzzling, since I'm set up as a personal app and it's supposed to grant access to intraday data immediately. I'm going to ask FitBit support about this, but do you all have any thoughts on this?

simonbromberg commented 6 years ago

Have you tried intraday or just intraday_all?

gravinamike commented 6 years ago

I've tried both, and now that I think on it again, intraday has both "activities-heart" and "activities-heart-intraday" keys in its fetch, and works fine on the same account, so it must not be the permissions.

The fetch commands that retrieve these different results differ only in their URL strings:

"https://api.fitbit.com/1/user/-/activities/heart/date/" + dateString + "/1d/1min.json" in intraday_all, which fails

versus

"https://api.fitbit.com/1/user/-/" + currentActivity + "/date/" + dateString+ "/" + dateString + ".json" in intraday, which succeeds.

I tried simply switching out the string from intraday for the one in intraday_all - wish it were that simple, but the error persists!

rileym94 commented 6 years ago

I'll be glad to test anything, just let me know what I can do to help. I work in IT so I have access to a code editor all day long at work. 👍