On a new WordPress site that I was working on I got an error message “The response is not a valid JSON response.” when I attempted to upload an image to a page via Gutenberg block editor.
After Googling it, I found a myriad of different solutions and troubleshooting steps to take but in the back of my mind I remembered encountering this before and remembered that it was a simple fix. One solution suggested using the Media Library upload button instead of the direct Upload button. This did actually did allow me to upload the image but when I went to save the page I got the error “Updating failed. Error message: The response is not a valid JSON response.”
Eventually I stumbled on the very simple solution – just update the Permalinks! After that, the problem was solved! It may not be the solution for every case of this error but definitely something to try if you are encountering this error.
Another thing worth checking is in Tools > Site Health check if there are any issues relating to Rest API (which is required by Gutenberg). In my case the permalinks issue also caused a Rest API misconfiguration to be noted in Site Health and once I updated the permalinks it was cleared.