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

Sleep Logs - Duration is out of bounds

ANSWERED

Hi,

 

When making a Sleep Log request we get this error - "Duration is out of bounds". It looks like a Sleep Log with a duration less than 10 minutes causes this error.  Is that correct? Is 10 minutes the minimum duration for a sleep log?

 

Thanks,

Chris

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Hi @bickster 

 

It looks like a sleep log needs to have a length between 10 and 1440 minutes.   I tried to manually enter a sleep log through the web site and got this message.

 

Screen Shot 2021-01-20 at 9.11.57 AM.png

 

We will make certain to include this requirement in the documentation.

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

View best answer in original post

Best Answer
0 Votes
4 REPLIES 4

Hi @bickster 

 

I'm not aware of a sleep duration less than 10 minutes causing a "duration out of bounds" error.   Would you please post the endpoint that you're executing and the exact status code and error message that you're receiving?

 

Thanks!

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes
Sure. Here’s a sample of a log file of the error. The log file was generated on iOS.

POST:https://api.fitbit.com/1.2/user/-/sleep.json
2021-01-17 11:36:02.219 PARAMS:{
date = "2020-12-20";
duration = 510000;
startTime = "23:26";
}
2021-01-17 11:36:02.219 +[FitbitApiHelper getSessionManager:]
2021-01-17 11:36:02.377 POST:FAILURE:{"errors":[{"errorType":"validation","fieldName":"date/startTime","message":"Duration is out of bounds"}]}:https://api.fitbit.com/1.2/user/-/sleep.json
{
"Accept-Language" = "en-US;q=1, de-US;q=0.9";
Authorization = "Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIyMjg1MzgiLCJzdWIiOiI1UDZZTUMiLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJzY29wZXMiOiJ3cHJvIHdudXQgd3NsZSB3d2VpIHdhY3Qgd3NldCIsImV4cCI6MTYxMjY1Njc2MiwiaWF0IjoxNjEwNTg3MDQzfQ.mroqj-95KS2fIC3rYb7_MegM53hTsuMsUawQRV3s0oU";
"Content-Type" = "application/x-www-form-urlencoded";
} COMPLETE ERROR: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)" UserInfo={NSLocalizedDescription=Request failed: bad request (400), NSErrorFailingURLKey=https://api.fitbit.com/1.2/user/-/sleep.json , com.alamofire.serialization.response.error.data={length = 106, bytes = 0x7b226572 726f7273 223a5b7b 22657272 ... 756e6473 227d5d7d }, com.alamofire.serialization.response.error.response= 0x283ec7100=""> { URL: https://api.fitbit.com/1.2/user/-/sleep.json } { Status Code: 400, Headers {
"Cache-Control" = (
"no-cache, private"
);
"Content-Encoding" = (
gzip
);
"Content-Language" = (
en
);
"Content-Type" = (
"application/json;charset=UTF-8"
);
Date = (
"Sun, 17 Jan 2021 16:36:02 GMT"
);
Server = (
cloudflare
);
Vary = (
"Origin,Accept-Encoding"
);
Via = (
"1.1 google"
);
"cf-cache-status" = (
DYNAMIC
);
"cf-ray" = (
"61317e2a4971efe4-EWR"
);
"cf-request-id" = (
07b2cd2e6e0000efe481b33000000001
);
"expect-ct" = (
"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"" );
"fitbit-rate-limit-limit" = (
150
);
"fitbit-rate-limit-remaining" = (
150
);
"fitbit-rate-limit-reset" = (
1438
);
"x-frame-options" = (
SAMEORIGIN
);
} }}
Best Answer
0 Votes

Hi @bickster 

 

It looks like a sleep log needs to have a length between 10 and 1440 minutes.   I tried to manually enter a sleep log through the web site and got this message.

 

Screen Shot 2021-01-20 at 9.11.57 AM.png

 

We will make certain to include this requirement in the documentation.

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes
Thanks for looking into this. We’ll update our code.
Best Answer
0 Votes