04-20-2018 07:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-20-2018 07:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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.
Accepted Solutions
04-24-2018 01:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-24-2018 01:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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!

04-23-2018 10:24
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



04-23-2018 10:24
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

04-23-2018 10:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-23-2018 10:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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?

04-24-2018 00:39
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-24-2018 00:39
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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?

04-24-2018 01:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-24-2018 01:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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!

