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

ERROR while trying Get Sleep Logs by Date Range

ANSWERED

I'm getting an error when trying to get sleep logs by Date Range. I'm trying to use this endpoint: https://dev.fitbit.com/build/reference/web-api/sleep/#get-sleep-logs-by-date-range

I do this exact call.

GET https://api.fitbit.com/1.2/user/-/sleep/date/2019-8-19/2019-8-28.json


And I get the following response.

{
    "errors": [
        {
            "errorType": "validation",
            "fieldName": "date",
            "message": "Invalid date: 2019-8-19/2019-8-28"
        }
    ]
}

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Hi @Mariusl 

 

To resolve this error, you need to specify a 2-digit value for month.  The correct syntax for date values with the Web APIs are YYYY-MM-DD.   Please try executing your endpoint as 

 

GET https://api.fitbit.com/1.2/user/-/sleep/date/2019-08-19/2019-08-28.json
Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

Hi @Mariusl 

 

To resolve this error, you need to specify a 2-digit value for month.  The correct syntax for date values with the Web APIs are YYYY-MM-DD.   Please try executing your endpoint as 

 

GET https://api.fitbit.com/1.2/user/-/sleep/date/2019-08-19/2019-08-28.json
Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

The missing padding on month was the mistake. Thanks!

Best Answer
0 Votes