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.
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)
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…)
Hi there! sorry to be slow to reply - there are quite a few API error issues on the Netlify CMS repo.
‘API ERROR’ is a common catch-all error message for a variety of different reasons.
Probably your best bet is to go and see if there is an issue that matches your circumstances - its possible there is a solution, or you are more than welcome to file a new one!
can i ask what is the main reason here when im uploading a image in netlify cms it shows “Failed to persist media: API_ERROR” but its uploading in our github repo.