I’m facing a really strange and frustrating issue with my Strapi (v4) project. I’ve been debugging this for a while and have tried almost everything I can think of. I’d greatly appreciate any help or new ideas.
The Problem in Detail
My GET requests for a “Todo” collection type work perfectly, but PUT requests to update an existing entry consistently fail with a 404 Not Found error, even when using a valid and existing ID.
Symptoms:
When I send a GET request to http://localhost:1337/api/todos, I get a 200 OK response with a list of all the items. I can clearly see the items and their IDs (for example, items with id: 2 and id: 4).
When I then use one of those valid IDs to send a PUT request to http://localhost:1337/api/todos/2, the request fails with a 404 Not Found error every single time.
The Strangest Clue: At one point during debugging, I noticed that the IDs displayed in the Strapi Admin Panel’s Content Manager were different from the IDs being returned by the API (e.g., the UI showed IDs 1, 3, 5 while the API returned 2, 4, 6). This suggested a database conflict or an issue with two server instances running, but the problem has persisted even after a full project reset.
My Question
What could possibly cause a 404 Not Found error on a PUT request for an ID that is confirmed to exist via a GET request, given that all permissions and configurations appear to be perfect?
Has anyone ever faced a similar “ghost” issue in Strapi? Any new debugging steps or ideas would be incredibly helpful.
Thanks in advance!
I have already gone through all the common solutions and confirmed the following:
Permissions: I have 100% confirmed that the permissions for find, findOne, and update are all enabled for the correct role (Public/Authenticated) in the Strapi Admin Panel.
Request Formatting: The request is formatted correctly for Strapi v4. The URL is correct (/api/todos/{id}), and the JSON Body is correctly wrapped in a data object: { “data”: { … } }.
Full Project Reset: I have stopped the server, deleted the .tmp, node_modules, and build folders, then ran npm install followed by npm run build to ensure a clean state.
Hardcoded URL: I have used the full, hardcoded URL (http://localhost:1337/api/todos/2) directly in Postman to rule out any issues with environment variables ({{host}}).
Custom Code: I have not modified the core controller or service for this content type. There are no custom policies applied to these routes.