04-20-2018 07:26
04-20-2018 07:26
Hi,
I am currently trying to get the sleep data over a period of time, but it seems as the API isn't understanding my request, although it is written in exact the same way, as the documentation says:
GET https://api.fitbit.com/1.2/user/[user-id]/sleep/date/[startDate]/[endDate].json
So I am requesting with:
GET https://api.fitbit.com/1.2/user/-/sleep/date/2018-04-15/2018-04-16.json
What I get is:
{"errors":[{"errorType":"validation","fieldName":"date","message":"Invalid date: 2018-04-15/2018-04-16"}]}
Looks like the API takes "2018-04-15/2018-04-16" as one date param instead of two, like it should.
Can you guys help me, or fix this please, as I'll need large amounts of sleep data and currently I can only get one sleep data for one day with each request...
Thanks 🙂
Answered! Go to the Best Answer.
04-24-2018 01:34
04-24-2018 01:34
Hi there,
@danmana Encoding was my guess as well, but it turned out, it was simple stupidity by myself 😄
@Gordon-C contacted me via PM and we figured out, I was using POST method instead of GET..
I didn't notice this, as the request for daily sleep was working perfect, but Gorden luckily saw it in the Fitbit logs.
Thanks for helping me with this!
Best Answer04-23-2018 10:24
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.
04-23-2018 10:24
Hi wangerowski,
I was not able to reproduce the error message you are receiving. Have you tried executing the same call within the Fitbit Web API explorer tool?
https://dev.fitbit.com/build/reference/web-api/explore/#/Sleep/sleep3
Best Answer04-23-2018 10:44
04-23-2018 10:44
Hi Gordon!
Call via Web API is giving me a 200.
But why isn't it working then with my request 😞
Obviously the api is using both dates as one param, when I try to call.
Do you have any idea why this could be happening?
Best Answer04-24-2018 00:39
04-24-2018 00:39
Hi,
I'm unable to reproduce the error with the URL you have given. Everything works (I tried in postman).
Are you sure you're not encoding the slash between the dates?
Best Answer04-24-2018 01:34
04-24-2018 01:34
Hi there,
@danmana Encoding was my guess as well, but it turned out, it was simple stupidity by myself 😄
@Gordon-C contacted me via PM and we figured out, I was using POST method instead of GET..
I didn't notice this, as the request for daily sleep was working perfect, but Gorden luckily saw it in the Fitbit logs.
Thanks for helping me with this!
Best Answer