infoWordPress CoreapiREST APIerrorerrorerrorwp_errorcodejsonsettingsserver_configurationlabelCommonwarningModerate

WP_Error: Invalid JSON response body

WordPress expects a JSON payload from its REST API. When the server sends HTML, an empty body, or a 403 page, the response fails to parse as JSON. This mismatch stops the editor from saving content and shows an error.

The problem usually stems from server settings, URL mismatches, rewrite rules, or code that outputs warnings before the JSON data.

Symptoms

[dashicons-warning]
Editor error banner
Gutenberg shows a red banner stating the response is not a valid JSON response.
[dashicons-admin-site]
HTML response in network tab
Browser network panel shows the REST request returning HTML or an empty body.
[dashicons-admin-generic]
Console WP_Error message
JavaScript console logs WP_Error: Invalid JSON response body.

Common Causes

Mismatched URLs
Site URL and Home URL use different protocols or domains, causing requests to hit the wrong address.
Broken permalinks
Rewrite rules send the API request to a 404 page or HTML output.
Plugin or theme output
PHP warnings, notices, or stray echo statements prepend HTML before the JSON payload.
Security or firewall block
ModSecurity or WAF rules block application/json requests and return a forbidden HTML page.
Need this fixed right now?

Don't waste your day debugging. Our experts can Fix your issues in under 2 hours.*

Success Rate

100% Guaranteed

Starting from

$35 /hour
99+

Trusted by Business Owners

“I spent 3 days trying to fix the Elementor loading loop. These guys fixed it in 20 minutes. Lifesavers!”

— Sarah J., Web Designer

Related Issues

contact_mail
Contact Form 7: REST API request failed: 503 Service Unavailable
A 503 Service Unavailable response stops Contact Form 7 from sending data...
apiREST APIerror503descriptioncontact-form-7
contact_mail
Contact Form 7: REST API request failed: 429 Too Many Requests

The form tries to send data through the WordPress REST API. The...

apiREST APIerrorerrorsecurityfirewalldescriptioncontact-form-7settingsserver_configuration
contact_mail
Contact Form 7: REST API request failed: 401 Unauthorized

The form tries to send data via the WordPress REST API. The...

apiREST APIadmin_panel_settingspermissionsdescriptioncontact-form-7lock401
contact_mail
Contact Form 7: File upload error: temporary directory missing

The error appears when Contact Form 7 cannot locate a writable temporary...

codePHPcloud_offupload erroradmin_panel_settingspermissionsdescriptiontemporary filedescriptioncontact-form-7
contact_mail
Contact Form 7: Mail (2) sending failed: PHP mail() function disabled

Contact Form 7 reports a failure for Mail (2) when the PHP...

codePHPerrorerrordescriptioncontact-form-7mailMailsettingsserver_configuration
contact_mail
Contact Form 7: Mail (2) sending failed: SSL certificate verification failed

Contact Form 7 reports a failure when trying to send the secondary...

errorerrorlocksslcodecURLdescriptioncontact-form-7