08-26-2019 06:57
08-26-2019 06:57
Hi @AndrewFitbit,
I have been trying to log food using the food log API with the foodName parameter. I am having issues with how this custom log appears on my Fitbit iOS app.
Here is my request:
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.fitbit.com/1/user/<user-id>/foods/log.json",
"method": "POST",
"headers": {
"authorization": "Bearer <token>",
"content-type": "application/x-www-form-urlencoded",
"cache-control": "no-cache",
"postman-token": "<token>"
},
"data": {
"date": "2019-08-26",
"foodName": "Potato Chips",
"mealTypeId": "4",
"unitId": "70",
"amount": "3.5",
"favorite": "false",
"brandName": "Lay's",
"calories": "60",
"biotin": "0",
"calcium": "0",
"caloriesFromFat": "52",
"cholesterol": "15",
"copper": "0",
"dietaryFiber": "0",
"folicAcid": "0",
"iodine": "0",
"iron": "0",
"magnesium": "0",
"niacin": "0",
"pantothenicAcid": "0",
"phosphorus": "0",
"potassium": "0",
"protein": "1",
"riboflavin": "0",
"saturatedFat": "3.5",
"sodium": "150",
"sugars": "1",
"thiamin": "0",
"totalCarbohydrate": "1",
"totalFat": "6",
"transFat": "0",
"vitaminA": "300",
"vitaminB12": "0",
"vitaminB6": "0",
"vitaminC": "0",
"vitaminD": "0",
"vitaminE": "0",
"zinc": "0"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});I get a perfectly normal response which is:
{
"foodDay": {
"date": "2019-08-26",
"summary": {
"calories": 280,
"carbs": 12,
"fat": 24,
"fiber": 2,
"protein": 5,
"sodium": 495,
"water": 0
}
},
"foodLog": {
"isFavorite": false,
"logDate": "2019-08-26",
"logId": 18990262XXX,
"loggedFood": {
"accessLevel": "PRIVATE",
"amount": 3.5,
"brand": "Lay's",
"calories": 60,
"foodId": 0,
"mealTypeId": 4,
"name": "Potato Chips",
"unit": {
"id": 70,
"name": "cookie",
"plural": "cookies"
},
"units": [
70
]
},
"nutritionalValues": {
"calories": 60,
"carbs": 1,
"fat": 6,
"fiber": 0,
"protein": 1,
"sodium": 150
}
}
}However, when I check the log on my phone (iOS 12.4, iPhone 8), I cannot see the foodName, brandName, or any of the nutritional information in the app, while it seems like it has been logged correctly in the request above. Here's a screenshot:
Could you please tell me what I am missing?
Thank you.
08-26-2019 11:29
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.
08-26-2019 11:29
Hi @cadenza_97
Are you able to see your food log through your web browser at fitbit.com?
Best Answer08-29-2019 02:34
08-29-2019 02:34
Hi @Gordon-C
I can see the log with name and brand on Fitbit.com:
I cannot click on food logged using the foodName API and have it open the Nutritional Information though. I was able to do that in the app, but the opened dialog box I attached in my previous post did not show necessary information.
Still not sure if I'm missing something with the API.
Best Answer