09-18-2019 08:43
09-18-2019 08:43
Hello, I'm finishing to implement the food and water feature on my php wrapper for the Fitbit API and during the testing stage I've discovered this issue that seems to conflict with what I've understood from the documentation.
If I create a food log using the foodName parameter instead of the foodId I create a private food, then if I try to update that food log from what I've read here I should be able to update the log just by passing mealTypeId and calories. So a query like this:
https://api.fitbit.com/1/user/-/foods/log/19248090616.json?mealTypeId=3&calories=3000
where 19248090616 is the id for the log entry I've just created should return a success code, however I'm getting the following error message:
Food log entry without food could not be updated.
That confuses me because the log entry I've just created has no foodId since it is a private food created using the foodName parameter.
I've searched the forums and found this old unanswered post stating that a foodName and not a foodId cannot be updated at all.
Should these entries be updated just by passing the appropriate parameters? Is there an error on the code? the documentation? Or did I just misunderstood it?
Thanks!
Answered! Go to the Best Answer.
09-25-2019 16:30
09-25-2019 16:30
Hi @namelivia,
I may have found something that may resolve the issue you are seeing. There is some clarification that needs to be done on our end in which logging food using a foodId with the Post Log Food endpoint may actually be required rather than optional/required.
According to the documentation I just linked above, there are 2 ways to log food, both of which I have tested on my end.
Based on the information above, can you try logging your food using method 1 and let me know if you are still coming across these issues?
I hope this helps. Let me know if you have any additional questions.
09-25-2019 16:30
09-25-2019 16:30
Hi @namelivia,
I may have found something that may resolve the issue you are seeing. There is some clarification that needs to be done on our end in which logging food using a foodId with the Post Log Food endpoint may actually be required rather than optional/required.
According to the documentation I just linked above, there are 2 ways to log food, both of which I have tested on my end.
Based on the information above, can you try logging your food using method 1 and let me know if you are still coming across these issues?
I hope this helps. Let me know if you have any additional questions.
09-26-2019 02:54
09-26-2019 02:54
Hello John and thanks for your answer.
Yes, creating and editing afterwards a food log entry that was created with foodId instead of foodName works. So I am guessing from your answer that yes, when the log was created using foodName it won't be editable at all by an API call. I'll consider that on my code, is not that I'm trying to edit a FoodLog myself but I'm creating a library so I needed to consider all possible scenarios in order to let my library cover the whole Fitbit API.
So I'll take note and won't let users update those logs (https://github.com/namelivia/fitbit-http-php/issues/35)
Thanks!