09-13-2015 09:14
09-13-2015 09:14
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.
09-20-2015 05:40
09-20-2015 05:40
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 Answer09-13-2015 14:11
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.
09-13-2015 14:11
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 Answer09-13-2015 14:28
09-13-2015 14:28
Hi 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 Answer09-20-2015 04:34
09-20-2015 04:34
Hi,
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 Answer09-20-2015 05:40
09-20-2015 05:40
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 Answer09-20-2015 10:54
09-20-2015 10:54
Thank you so much TheYann 🙂
Best Answer09-20-2015 11:13
09-20-2015 11:13
You are very welcome sir 🙂
Best Answer09-29-2015 05:46 - edited 09-29-2015 05:48
09-29-2015 05:46 - edited 09-29-2015 05:48
THIS 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 Answer09-29-2015 10:47
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.
09-29-2015 10:47
@MissEllen: There indeed is no document tree. You'll need to parse the server's response as JSON instead of XML.
Best Answer