Food Search Not Working

Options
When I search for a certain food and hit the button that says Add Food to Diary, it takes me to a page that says: Page Not Found. I've cleared my cache, but it still is not working. Any suggestions?

Best Answers

  • durden
    durden Posts: 3,201 MFP Staff
    Answer ✓
    Options
    Please reach out to our dedicated support team for assistance by visiting https://myfitnesspal.zendesk.com/hc/en-us or emailing directly to support@myfitnesspal.com
  • metal_hurlant
    metal_hurlant Posts: 3 Member
    Answer ✓
    Options
    Found a workaround. Instead of using the "Add Food" links in the diary that take you to /food/search and will ultimately fail, click on the "Database" link in the top sub-menu under the "Food" menu, then search and add your foods there.
    This will hit an endpoint that works and you'll be able to add foods to your diary that way.

Answers

  • VanWertWest
    VanWertWest Posts: 1 Member
    Options
    I have been having the same problem, since 4/26/24.
  • matthewneiger2
    matthewneiger2 Posts: 1 Member
    Options
    Same.
  • metal_hurlant
    metal_hurlant Posts: 3 Member
    Options
    Same.
    The "add food to diary" buttons submits a POST to /food/add, which redirects to /accounts/login?callback=.../food/add, which loads a GET to /food/add with all the form data missing, which shows an outdated "page not food" error.
    So probably a bad authentication check in the /food/add handler or something.
  • metal_hurlant
    metal_hurlant Posts: 3 Member
    Options
    Alright, last post to this thread I swear.
    If you understand what a userscript is and you're comfortable using them, here's one that will take you to the database search page when you focus the search bar on an "add food" pages, keeping you away from the broken bits.
    It's a tradeoff, as you'll need to adjust the day and meal yourself on every add, but it's what I'm using until this gets fixed.
    // ==UserScript==
    // @name         MFP add food bug workaround
    // @namespace    http://tampermonkey.net/
    // @version      0.1
    // @description  route around damaged /food/add API
    // @author       metal_hurlant
    // @match        https://www.myfitnesspal.com/food/*
    // @match        https://www.myfitnesspal.com/user/*/diary/add
    // @icon         https://www.google.com/s2/favicons?sz=64&domain=myfitnesspal.com
    // @run-at       document-start
    // ==/UserScript==
    addEventListener('load', _=>({
      add_to_diary() { document.querySelector('#search').addEventListener('focus', _=> location.assign('/food/calorie-chart-nutrition-facts')) },
      add() { this.add_to_diary() },
      'calorie-chart-nutrition-facts': _=> document.querySelector('[name="searchInput"]').focus()
    })[location.pathname.split('/').at(-1)]?.());
    

  • HealtheSS
    HealtheSS Posts: 6 Member
    edited May 1
    Options
    Just tried it this morning & it's working now! Thanks for all your replies! :)
  • Ll0ydD0bler
    Ll0ydD0bler Posts: 17 Member
    Options
    The problem went away for me for a single food item but otherwise I'm still having it. I can add food on the phone app so that's my workaround but I hate it.
  • lmiles2005
    lmiles2005 Posts: 1 Member
    Options
    I'm having the very same issue, so I copied and pasted from a previous post: When I search for a certain food and hit the button that says Add Food to Diary, it takes me to a page that says: Page Not Found. I've cleared my cache, but it still is not working.