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

Food Logs that have been created using the foodName parameter can't be updated

ANSWERED

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!

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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.

 

  1. The common approach is to use foodId and create the entry with a link to the food from the Food DB (Search Foods) or to the user's private food (Create Food). Fitbit recommends each integration use this first approach, when possible. 
    1. This means that you must first create the food item using the Create Food endpoint in order to receive a foodId for your food log. Once you have obtained a foodId property, you will need to use that to log your food with the POST Food Log endpoint instead of using foodName. This would result in logging an editable food log from the app.
  2. The second approach is used if you want just to upload some history data or to log a daily intake summary only (or several specific meal's summaries) for the user the foodName parameter might be helpful. In this case, you should also explicitly provide the calories and optionally brandName (or source name) and a full set of nutritional values for this log entry. Entries logged via foodName can not be edited on the website or added to the list of favorites. 
    1. This appears to be the scenario you are coming across since you are logging food logs explicitly with the foodName value instead of a foodId, and not being able to edit the food log.

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.

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

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.

 

  1. The common approach is to use foodId and create the entry with a link to the food from the Food DB (Search Foods) or to the user's private food (Create Food). Fitbit recommends each integration use this first approach, when possible. 
    1. This means that you must first create the food item using the Create Food endpoint in order to receive a foodId for your food log. Once you have obtained a foodId property, you will need to use that to log your food with the POST Food Log endpoint instead of using foodName. This would result in logging an editable food log from the app.
  2. The second approach is used if you want just to upload some history data or to log a daily intake summary only (or several specific meal's summaries) for the user the foodName parameter might be helpful. In this case, you should also explicitly provide the calories and optionally brandName (or source name) and a full set of nutritional values for this log entry. Entries logged via foodName can not be edited on the website or added to the list of favorites. 
    1. This appears to be the scenario you are coming across since you are logging food logs explicitly with the foodName value instead of a foodId, and not being able to edit the food log.

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.

Best Answer
0 Votes

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!

Best Answer
0 Votes