10-25-2019 11:34
10-25-2019 11:34
The documentation in this section https://dev.fitbit.com/build/reference/web-api/food-logging/#logging-and-deleting-collection-data is not clear on how to log the nutrition for a food using the foodName (second method).
It says " you should also explicitly provide the calories and optionally brandName (or source name) and a full set of nutritional values for this log entry". I have tried sending the following data.
{'foodName': 'pilchard sandwich', 'date': '2019-10-25', 'amount': 1, 'unitId': 168, 'mealTypeId': 3, 'favorite': false, 'fat': 21.57, 'carbohydrate': 53.25, 'fiber': 3.22, 'alcohol': 0.0, 'protein': 46.07, 'saturated_fat': 8.31, 'sugar': 12.54, 'calories': 589}
The food was created, and calories registered. But nutrition information was not recorded. The response from the API was successful (201) but as follows,
{"foodDay":{"date":"2019-10-25","summary":{"calories":4237,"carbs":103.11,"fat":39,"fiber":10.32,"protein":229.07,"sodium":1637.87,"water":1182.94}},"foodLog":{"isFavorite":false,"logDate":"2019-10-25","logId":196063097,"loggedFood":{"accessLevel":"PRIVATE","amount":1,"brand":"","calories":589,"foodId":0,"mealTypeId":3,"name":"pilchard sandwich","unit":{"id":168,"name":"item","plural":"items"},"units":[168]},"nutritionalValues":{"calories":589,"carbs":0,"fat":0,"fiber":0,"protein":46.07,"sodium":0}}}'
What format should the post data be for the nutrition info (other than calories) to be stored too ?
Thank you,
10-28-2019 11:46
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.
10-28-2019 11:46
I agree the documentation could be better in this area. Would you please provide the endpoint syntax you used to log this food entry?
Thanks!
Gordon
Best Answer