enable REST API
-
I am getting below error message in site health, i want to know how to solve this
<<<<<<< ERROR >>>>>>>>>>>>>>
The REST API encountered an unexpected result
Performance
The REST API is one way that WordPress and other applications communicate with the server. For example, the block editor screen relies on the REST API to display and save your posts and pages.When testing the REST API, an unexpected result was returned:
REST API Endpoint: https://karkala.org/wp-json/wp/v2/types/post?context=edit
REST API Response: (404) Not Found
<<<<<<< END OF ERROR >>>>>>>>>>>>>>As someone suggested to add these 2 lines in
wp-config
define(‘WP_REST_API_DISABLED’, false);
define(‘ENABLE_REST_API’, true);
Still no Luck.If any plugin blocks it or disable it then i have other sites where i use same plugins and it works
If so what went wrong?
Any ExpertThe page I need help with: [log in to see the link]
-
The REST API is normally always activated unless it is intentionally deactivated. The latter can happen, for example, through plugins that interfere here. Security plugins or caching plugins would be possible here. Therefore, check whether you have a security plugin and deactivate it as a test.
When I visit your site, I also notice that I have to confirm that I am human every time I visit. This could possibly be caused by Litespeed and I would also recommend that you check whether this is the cause.
Thank you for the speedy reply.
I suspected SPAM BEE bot blocker plugin and disabled it, still same problem, but SPAM BEE is not the reason where on other website all same plugins installed and REST API is working.
and other Human Verification Turnstile plugin loads every time even after you verified once, informed plugin owner but he is not ready to admit that there is bug in his plugin blaming other plugins and his plugin also blocks the comments.
i disabled both SPAM BEDD and reCaptcha Turnstile still REST API is down. it was never intentionally disabled but i am not finding any option to enable it or make it run, thats the issue.
Then deactivate all plugins to rule them out as the cause. If it then works again, activate them bit by bit until it no longer works – then you have found the culprit plugin.
The theme can also be a cause. Change it to a standard theme (such as TwentyTwentyFive) to rule it out as a possible cause.
Also go to Settings > Permalinks and save them again – just as an experiment.
The best way to check whether the REST API is accessible is via the URL /wp-json/ that you call up in the browser. If there is no 404 page, then it is accessible.
Thank you Again.
before posting here
I have disabled all plugins,
Saved Permalinks(twice)
Cleared Cache from server sideStill same issue.
I have other websites on same webhost with similar and more other plugins, where REST API works, so its not the other pluginThis website is almost 10/15 years old, there are plenty of old autoloaders still in wp_options, WORDPRESS has no options to force plugin developers add options to clear their junk once their plugin is uninstalled nor there is any plugin to clear it. May be some autoloader still keep it down.
Anyway I will change the theme and will see. and update if its working.
Question is even after adding in WP config file why its not starting
Constants called “WP_REST_API_DISABLED” or “ENABLE_REST_API” do not exist in WordPress. Therefore, the two lines cannot do anything:
https://github.com/search?q=repo%3AWordPress%2FWordPress%20WP_REST_API_DISABLED&type=code
https://github.com/search?q=repo%3AWordPress%2FWordPress+ENABLE_REST_API&type=codeI don’t know where you got this from, but there are many sources on the net that can write anything. I would recommend that you rely on the documentation at wordpress.org.
How to technically deactivate the REST API is described here: https://developer.wordpress.org/rest-api/frequently-asked-questions/#can-i-disable-the-rest-api
Since I assume you have not done this, I would continue to guess that there is something wrong with your project or hosting. Another thing that stands out for me is that when you call the REST API, you get a 404 page from your host Hostinger. So it might be a good idea to contact their support.
Constants called “WP_REST_API_DISABLED” Ifound here, its not my creation
https://stackoverflow.com/questions/60216816/how-can-i-enable-rest-api-on-my-wordpress-web-siteit can be technically disabled and same way there should be way to enable it. As some plugins disable it, why not some plugin to enable it?
My question is HOW TO ENABLE IT.
On Hostinger I have a dozens of websites with almost similar plugings/theme and also created other website with same plugin and theme but REST API is working. so i cannt blame them or ask to fix it.
As i told you this website ise very old, some conflicting plugin disabled it, as I install uninstall many plugins, when i found better one or when Author abandon the update of works only with older version of PHP.
My Question what is the way to make it work again
The answer under your link was downvoted so negatively for a reason. It is wrong.
Is there anything else in the
wp-config.php?Regardless of this, I would still try to contact the hoster’s support team, even if it doesn’t seem helpful to you. They are the only ones who have access to your project and could also check for you whether something is wrong.
The alternative would be for you to find someone to look into it with you. You can find someone like this here, for example: https://jobs.wordpress.net/
I spoke to Hostinger team, they will not do much in helping issue than suggest to restore from backup.
While fixing this issue i changed many settings and configuration, tweeked and removed unwanted themes and plugins, so i cannt restore to earlier backup.These are other defines of wp-config
define('WP_DEBUG', false); define('WP_POST_REVISIONS', false ); define('CONCATENATE_SCRIPTS', false); define('EMPTY_TRASH_DAYS', 0 ); define('DISABLE_WP_CRON', true); define( "WP_USE_MULTIPLE_DB", false ); define('WP_ALLOW_MULTISITE', true); define( 'AUTOSAVE_INTERVAL', 300 ); define( 'WP_CRON_LOCK_TIMEOUT', 120 ); define( 'FS_METHOD', 'direct' ); define( 'WP_AUTO_UPDATE_CORE', true );removed REST API option from above.
myself System admin/Webmaster I support and manage websites for charities and NGOs, I will work on it myself and fix the issue.
After all there is no option to start REST API or no one knows how to start it.
I asked Hostinger to reboot my node but its on shared hosting so they will not do that.Anyway, any help is much appreciated.
After hours of REsearch (searching again and again on internet)
I found 2 plugin
Autoload checker(to check autoloader)
and
WP Crontrol (enables you to take control of the scheduled cron events)and this is the result
If this is an option, it must be set and read by a plugin you are using. When I searched for it, I only found 3 plugins in the entire WordPress repository that use it:
- Disable REST API
- Independent Analytics – Google Analytics Alternative for WordPress
- XL NMI Gateway for WooCommerce
Do you have one of these? If not, it could also be a remnant of a previously installed plugin that is no longer used.
None of them are installed.
May be Independent Analytics installed once for test.
there is so much junk in wp_option many leftover autoloader still loading, I am in process of remove all manually which take time as i have to verify those are active and required or not.
3D FlipBook : Dflip Lite
AddToAny Share Buttons
bbPress
Default Sort Ascend
Easy Google AdSense
IndexNow
Inline Related Posts
Minify HTML
WP-Members
WPCode Lite
XML Sitemap Generator for Googlethese are the plugins installed, no special security plugin
Still question remains, HOW TO START REST API.
After lot of RnD and RE search finally i managed to REST API work.
REST API Endpoint: https://karkala.org/wp-json/wp/v2/types/post?context=edit
{“code”:”rest_forbidden_context”,”message”:”Sorry, you are not allowed to edit posts in this post type.”,”data”:{“status”:401}}
As there was no Security plugin which disable/Block it but when i searched WP_OPTION file in database there was entry showing DISABLE REST API. I deleted that entry with PhpmyAdmin still problem was same
then I found one Plugin “Advanced Database Cleaner” which shows all entries in WP_OPTION and allow you to delete it, Its Pro version shows which entry is belongs to which plugin, as i was not having Pro version I gone through each entry one by one, and deleted all leftover junk by earlier plugins.
By default Site health check was set to weekly with “WP Crontrol” i changed it to daily.
I also read LiteSpeed Cache Plugin use REST API so i uninstalled LiteSpeed and deleted all its more than 400 entries from WP_OPTION and there it is.
Surekha… Surekha….. It started to work
(Surekha is Indian Girl name)
The topic ‘enable REST API’ is closed to new replies.