[Common Issue] Netlify CMS API_ERROR. Now what?

At the moment the Netlify CMS API errors are a little vague, it’s a work in progress. Most of these issues have been posted here before, but I think it’d be useful to have an overview because they all look pretty much alike:


API_ERROR: {"message":"404 File Not Found"}

As far as I know there are two scenarios that cause this error:

  • The collection folder or file property is missing a value (a dedicated file or folder, can’t be blank or root). The file or folder should be relative to root (so src/posts for example).
  • There are subfolders within the collection folder

API_ERROR: Not Found
  • The media library folder is missing, or the value of the media library property within config.yml isn’t correct.

Failed to load entries: API_ERROR: Not Found
  • Git Gateway is not enabled: Enable Git Gateway from the Netlify Identity settings or refresh the token
  • There aren’t any entries for a given collection. Nothing serious, if you add content the error will go away.

Failed to load entry: API_ERROR: Not Found
  • The collection folder or file property is missing a value (a dedicated file or folder, can’t be blank or root). The file or folder should be relative to root (so src/posts for example).
  • There aren’t any entries for a given collection. Nothing serious, if you add content the error will go away.

Failed to persist entry: API_ERROR: Not Found

Not really an API error but pretty easy to resolve:

Failed to load settings from /.netlify/identity
  • Netlify Identity isn’t enabled
  • config.yml has git-gateway as a backend on a site that isn’t hosted on Netlify
3 Likes
Failed to persist entry: API_ERROR: Reference update failed
  • You’re using the editorial workflow but already have a branch called cms. This error is fixed by removing the cms branch from the repo.
1 Like

One of my writers has been experiencing intermittent 502 errors when saving articles, which doesn’t seem to be covered here yet…

The site is hosted on Netlify, the code is hosted on Github.

She copied the following from the console:

Uncaught (in promise) 
Object
error: API_ERROR at new t (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:51:142563) at new i (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:51:142870) at l.handleRequestError (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:512:27848) at l.request (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:51:159613) at async l.uploadBlob (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:55:8385) at async Promise.all (index 0) at async l.persistFiles (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:55:602) at async t.runWithLock (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:218:12733) at async K.persistEntry (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:28:83406) at async https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:48:59138
api: "Git Gateway"
message: undefined
meta: {}
name: "API_ERROR"
status: 502
stack: "API_ERROR↵    at new t (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:51:142563)↵    at new i (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:51:142870)↵    at l.handleRequestError (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:512:27848)↵    at l.request (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:51:159613)↵    at async l.uploadBlob (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:55:8385)↵    at async Promise.all (index 0)↵    at async l.persistFiles (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:55:602)↵    at async t.runWithLock (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:218:12733)↵    at async K.persistEntry (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:28:83406)↵    at async https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:48:59138"
__proto__: Error
payload:
collection: "articles"
error: API_ERROR at new t (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:51:142563) at new i (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:51:142870) at l.handleRequestError (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:512:27848) at l.request (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:51:159613) at async l.uploadBlob (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:55:8385) at async Promise.all (index 0) at async l.persistFiles (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:55:602) at async t.runWithLock (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:218:12733) at async K.persistEntry (https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:28:83406) at async https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js:48:59138
slug: "2020-11-23-xxx"
__proto__: Object
type: "UNPUBLISHED_ENTRY_PERSIST_FAILURE"
__proto__: Object

Any idea what’s going on here and what we can do about it?

Is it possible that her authentication token times out while she is authoring? She can tell by doing this experiment:

If when encountering the error, she goes to load the same URL that she shows while editing in another tab - does it work, or does it make her login again? If it makes her login again - does the NEXT save (after she logs in, and returns to original tab) work?

I see this on some of my sites and am very careful to save my work before the auth token expires (which on that site is once an hour, not sure if you have a similar setup or no - you could plug the contents of nf_jwt cookie into https://jwt.io to see what your expiry is)

Hi @fool, thanks for your response!

I ran into the same issue now myself so I had a chance to check the JWT token. It seems to also have a 1 hour expiry, however I’m getting the error while it’s still valid (currently 20 minutes since I logged in, and 40 minutes left on the clock according to jwt.io).

Opening the article editor in a new tab also doesn’t ask me to log in again (it just asks if I want to restore a local backup of the article).

Any other ideas?

(Note: when trying to click save again a minute or two later it worked just fine…)