I've been trying to play with Fitbit API and found that I cannot log water usage.
The URL in question is https://api.fitbit.com/1/user/-/foods/log/water/date/2015-09-12.json
The problem is: if I issue GET request to this endpoint, I can get a list of water log, which indicates there's no problem in the OAuth header, nor the URL itself. But when I send POST request with appropriate form field I got 404 back with the following content:
&{404 Not Found 404 HTTP/1.1 1 1 map[Date:[Sun, 13 Sep 2015 03:21:20 GMT] Server:[nginx] Expires:[Thu, 01 Jan 1970 00:00:00 GMT] Content-Type:[application/json;charset=UTF-8] Vary:[Accept-Encoding] Pragma:[no-cache] X-Frame-Options:[SAMEORIGIN] X-Ua-Compatible:[IE=edge,chrome=1] Set-Cookie:[JSESSIONID=XXXXXXXXXXXXXXXXXXXXXXXXXX.fitbit1; Path=/; HttpOnly] Www-Authenticate:[OAuth realm="https%3A%2F%2Fapi007-g4.prod.dal05.fitbit.com"] Cache-Control:[no-store, no-cache, must-revalidate]] 0xc8200122a0 -1 [chunked] false map[] 0xc8200d22a0 0xc82044c4d0}
{"errors":[{"errorType":"not_found","fieldName":"n/a","message":"The API you are requesting could not be found."}],"success":false}What's the problem?
Answered! Go to the Best Answer.
The api for logging water is https://api.fitbit.com/1/user/-/foods/log/water.json.
In POST with Form Encoded parameters, it works for me. Hope this helps.
Fitbit please fix your documentation 🙂
Best Answer
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.
That is the endpoint to retrieve water logs on a particular day. But it's not the endpoint if you want to createa new water log. See the documentation at https://dev.fitbit.com/docs/food-logging/#log-water
Best AnswerHi Jeremiah,
Thank you for your reply. Reading the document, read and write water log use the same URL I assume?
POST /1/user/[user-id]/foods/log/water/date/[date].json GET /1/user/[user-id]/foods/log/water/date/[date].json
Best AnswerHi,
I have the same problem.
Documentation indicates indeed that the urls for getting and posting water log are the same, but the error message I get is exactly the same as yegle had.
I tried post with query params and with form encoded fields but I get the same error.
{"errors":[{"errorType":"not_found","fieldName":"n/a","message":"The API you are requesting could not be found."}],"success":false}
So I guess the documentation is incorrect, FitBit could you check it out ?
Best AnswerThe api for logging water is https://api.fitbit.com/1/user/-/foods/log/water.json.
In POST with Form Encoded parameters, it works for me. Hope this helps.
Fitbit please fix your documentation 🙂
Best AnswerTHIS IS THE ANSWER I GET WHEN I GO TO THAT WEBSITE https://api.fitbit.com/1/user/-/foods/log/water.json
This XML file does not appear to have any style information associated with it. The document tree is shown below.
AND THERE IS NO "DOCUMENT TREE"
Best Answer
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.
@MissEllen: There indeed is no document tree. You'll need to parse the server's response as JSON instead of XML.
Best Answer