Title: REST API error
Last modified: March 8, 2022

---

# REST API error

 *  Resolved [Devomo](https://wordpress.org/support/users/devfirst/)
 * (@devfirst)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/rest-api-error-30/)
 * In [thread #15439077](https://wordpress.org/support/topic/could-not-connect-to-the-wordpress-rest-api/page/2/#post-15439077)
   I was advised to create a new thread specific to my issue, so here it is. I get
   the following error whenever I try to save some setting from the SG Optimizer
   settings screen:
 * > COULD NOT CONNECT TO THE WORDPRESS REST API
   >  Either a security plugin, custom
   > function, or rules in your .htaccess file is preventing the WordPress REST 
   > API from working properly. SiteGround Optimizer is using it to store its options
   > and other functionalities so please make sure it works properly.
 * WordPress: 5.9.1
    PHP: 7.4 SG Optimizer: 7.0.6 Web server: Apache Active theme:
   Twenty Twenty-Two Active plugins: SG Optimizer, no other
 * My .htaccess looks like this:
 *     ```
       <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
       RewriteBase /
       RewriteRule ^index\.php$ - [L]
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule . /index.php [L]
       </IfModule>
       ```
   
 * I’m willing to share credentials if that helps. I’m not a SiteGround customer,
   but I really like the plugin, so it would be great if I would be able to use 
   it.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Frest-api-error-30%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Support [Georgi Ganchev](https://wordpress.org/support/users/georgiganchev/)
 * (@georgiganchev)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/rest-api-error-30/#post-15439505)
 * Hello [@devfirst](https://wordpress.org/support/users/devfirst/)
 * Thank you for posting a new thread.
 * It is not possible to share login details here in the forum and we will not ask
   you to do so.
 * The REST API seems to be working on your website:
 * > Georgi-Ganchev$ curl -I [https://updatest.subliem.online/wp-json](https://updatest.subliem.online/wp-json)
   > 
   > HTTP/2 200 x-powered-by: PHP/7.4.27 x-robots-tag: noindex link: <[https://updatest.subliem.online/wp-json/&gt](https://updatest.subliem.online/wp-json/&gt);;
   > rel=”[https://api.w.org/&#8221](https://api.w.org/&#8221); x-content-type-options:
   > nosniff access-control-expose-headers: X-WP-Total, X-WP-TotalPages, Link access-
   > control-allow-headers: Authorization, X-WP-Nonce, Content-Disposition, Content-
   > MD5, Content-Type x-cache-enabled: False allow: GET vary: User-Agent content-
   > type: application/json; charset=UTF-8 date: Tue, 08 Mar 2022 21:45:15 GMT server:
   > Apache/2
 * I have reviewed the details of your application and tested a brand new vanilla
   setup on my end which results in no Rest API errors. Would you please confirm
   that you see this error when you navigate to the Caching menu in SiteGround Optimizer?
   Could you please check the Site Health and see if there are any particular errors
   reported there?
 * In addition, would it be possible to check if there are any specific errors in
   the php_errorlog? You can ask your remote host to review if the server logs are
   indicating a problem and let us know if anything related is found.
 * Best regards,
    Georgi Ganchev
    -  This reply was modified 4 years, 1 month ago by [Georgi Ganchev](https://wordpress.org/support/users/georgiganchev/).
    -  This reply was modified 4 years, 1 month ago by [Georgi Ganchev](https://wordpress.org/support/users/georgiganchev/).
 *  Thread Starter [Devomo](https://wordpress.org/support/users/devfirst/)
 * (@devfirst)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/rest-api-error-30/#post-15439654)
 * Hi Georgi,
 * > It is not possible to share login details here in the forum and we will not
   > ask you to do so.
 * I understand that, but if needed, I can share them privately.
 * > The REST API seems to be working on your website.
 * Can confirm that, the block editor for instance works fine.
 * > Would you please confirm that you see this error when you navigate to the Caching
   > menu in SiteGround Optimizer?
 * Well, what I get is a pop-up ‘Get the most out of this plugin’ and if I then 
   try to click ‘Confirm’, it shows the error. I can hide the pop-up by clicking
   outside of it, but when I then try to change a setting, the error reappears.
 * > Could you please check the Site Health and see if there are any particular 
   > errors reported there?
 * It reports only one problem: imagick is not installed. I can’t imagine this is
   the cause of the problem.
 * > In addition, would it be possible to check if there are any specific errors
   > in the php_errorlog? You can ask your remote host to review if the server logs
   > are indicating a problem and let us know if anything related is found.
 * I was able to view the log, but it was empty. I also tried to turn on WP_DEBUG_LOG,
   but that did not yield any results either; no errors were reported.
 * However, my JS console said the following:
 * > Failed to load resource: the server responded with a status of 405 ()
 * Does that provide any insight?
 * I can also share the Site Health info if that’s okay to do on the forum?
 *  Plugin Support [ivandzh](https://wordpress.org/support/users/ivandzh/)
 * (@ivandzh)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/rest-api-error-30/#post-15440358)
 * Hello [@devfirst](https://wordpress.org/support/users/devfirst/).
 * The returned 405 error indicates that the specified request was recognized by
   the server, but the server itself has rejected the method used for the accessed
   resource.
 * In order to verify if this is what’s causing the problem, is it possible to provide
   us with the name of the affected script?
 * Including any errors reported by the Site Health tool would also be useful, as
   long as they do not contain sensitive information.
 * Best regards,
    Ivan Dzhangozov
 *  Thread Starter [Devomo](https://wordpress.org/support/users/devfirst/)
 * (@devfirst)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/rest-api-error-30/#post-15440850)
 * Hi [@ivandzh](https://wordpress.org/support/users/ivandzh/),
 * Thanks for replying! I have managed to narrow down the issue a bit. The problem
   is: my server does not allow PUT requests.
 * In WordPress core, this never is a problem, because WordPress always only uses
   GET/POST request methods. However, the REST API allows other methods te be registered
   too, which is what the plugin does. But the REST API also allows you to _override_
   the request method using the query string or a header, see [https://developer.wordpress.org/rest-api/extending-the-rest-api/routes-and-endpoints/#http-methods](https://developer.wordpress.org/rest-api/extending-the-rest-api/routes-and-endpoints/#http-methods).
   The WordPress developers seem to have taken into account servers like mine, which
   do not allow other methods than GET/POST/HEAD.
 * This would in practice mean that you guys can replace the PUT request by a POST
   request and then override the method using one of the tricks described on the
   page linked above. This should only require a change in the plugin’s JS, not 
   in the REST route registration.
 * Of course, I can try to change the configuration of my server to allow PUT requests.
   But since there were more people on the forum who reported the same problem, 
   and since WordPress itself provides a mechanism to work around this, would it
   be possible for you guys to implement this in the plugin?
 * Cheers!
 *  Plugin Support [Dimitar Petrov](https://wordpress.org/support/users/demiro/)
 * (@demiro)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/rest-api-error-30/#post-15441123)
 * Thank you for your collaboration.
 * I have reported the case to our developers and they will consider the requested
   feature.
 * Best Regards,
    Dimitar Petrov
 *  Thread Starter [Devomo](https://wordpress.org/support/users/devfirst/)
 * (@devfirst)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/rest-api-error-30/#post-15441596)
 * Thanks [@demiro](https://wordpress.org/support/users/demiro/)! Really appreciate
   the support thus far.
 *  Plugin Support [Dimitar Petrov](https://wordpress.org/support/users/demiro/)
 * (@demiro)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/rest-api-error-30/#post-15445115)
 * Hello,
 * Our developers have discussed the case and decided that at this stage the requested
   modification cannot be applied. Indeed, the WordPress application allows overriding
   HTTP methods used by the client, however, this is a workaround for specific environments
   and not the standard. We follow strictly the standards and best practices.
 * If you maintain such an environment, I would recommend allowing all default HTTP
   verbs required by the WordPress app.
 * Regards,
    Dimitar
 *  Thread Starter [Devomo](https://wordpress.org/support/users/devfirst/)
 * (@devfirst)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/rest-api-error-30/#post-15448520)
 * Hi there,
 * Thanks for the reply and the time invested in this. I have contacted my hosting
   company in order to find out whether they can help me allow all HTTP methods.
 * While this is not the outcome I wished for, I understand and respect the decision.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘REST API error’ is closed to new replies.

 * ![](https://ps.w.org/sg-cachepress/assets/icon-256x256.gif?rev=2971889)
 * [Speed Optimizer - The All-In-One Performance-Boosting Plugin](https://wordpress.org/plugins/sg-cachepress/)
 * [Support Threads](https://wordpress.org/support/plugin/sg-cachepress/)
 * [Active Topics](https://wordpress.org/support/plugin/sg-cachepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sg-cachepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sg-cachepress/reviews/)

 * 8 replies
 * 4 participants
 * Last reply from: [Devomo](https://wordpress.org/support/users/devfirst/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/rest-api-error-30/#post-15448520)
 * Status: resolved