SOLVED Bedrock's /wp endpoint breaking rest api?

Hey, i recently upgraded to wp 4.4 which is integrating the wp rest api into core.

Before I was using the plugin and everything was working like a charm.

Now I upgraded to 4.4, happily disabled the plugin, and noticed that they have changed the endpoint to wp-json/wp/v2 (before it was just /wp-json).

Now on all my API calls I’m getting a

{“code”:“rest_no_route”,“message”:“No route was found matching the URL and request method”,“data”:{“status”:404}}

I had the feeling that this has to do with bedrocks /wp choice for the wordpress root. Am I totally wrong? or might this be the issue?

Thanks ahead and nice greetings from Europe,

J

Part of it

You still need the plugin

REST API infrastructure: Infrastructure for the REST API has been integrated into core, the first part of a multi-stage rollout. Inclusion of core endpoints is targeted for an upcoming release. To get a sneak peek of the core endpoints, and for more information on extending the REST API, check out the official WordPress REST API plugin.

1 Like

re-activated REST API plugi v1.2.4 and getting the same error.
does work on a fresh wordpress (without bedrock).

any of you guys tried the REST API plugin with bedrock and wp 4.4? Is it working?

Yeah, I tested it this morning before replying. I cloned the latest develop branch of the plugin to test

Ok got it, I was using REST API plugin 1.2.3, not 1.2.4!

:frowning:

I changed to 1.2.4, and its working again.

In the meantime I had also tried 2.0 beta8, which again did not work. Would be interesting to hear if 2beta8 with WP 4.4 and bedrock is working on your setup.

Thanks a lot anyways!

1 Like

The problem could be incompatibility between v1 and v2, if you left both plugins on.

This worked for me…

I have some issue also with wp rest api.

Actually I use like the documentation says adding /wp-json/wp/v2/posts but the only thing happens is the web site reload and when I use Postman tool I have back the index html.

The version I use from wp-rest-api is Version 2.0-beta13 and wp is the 4.5.1

Somone have the same issue or any idea how can I fix that?

Thanx!

1 Like

Did you find a solution @jdaquila? I hit the same snag as you mention above…

Hi @iamchriswick - I set all this up today and it’s working fine on the default route (i.e. wordpress.dev/wp-json/wp/v2/posts)

I’m using the latest bedrock (tag 1.7.2), WP v4.6.1 and rest-api 2.0-beta15.

If it helps, here’s my working nginx and php-fpm configs:

Nginx:

upstream wordpress {
  server 127.0.0.1:5000;
  keepalive 64;
}

proxy_http_version 1.1;

server {
  listen 80 default_server;
  server_name wordpress.dev;

  root /app/wordpress/current/web;
  index index.php;

  client_max_body_size 50m;

  location ~* ^.+\.(css|js|jpg|png|gif)$ {
    access_log off;
    log_not_found off;
    expires max;
  }

  location / {
    try_files $uri $uri/ /index.php?$args;
  }

  location ~ \.php$ {
    try_files $uri =404;

    fastcgi_pass wordpress;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

php-fpm:

[wordpress]
listen = 127.0.0.1:5000
chdir = /

For jdaquila, iamchriswick and anybody else who bumped into this:
I hit the same problem after installing bedrock out of the box.

Just to be clear, as of wp4.7, you don’t need a separate plugin for wp-json anymore. It’s in the core.

What you need to do is to reset the permalinks. I added a muplugin myself: force-postname-permalinks.php in the mu-plugins folder:

<?php
/*
Plugin Name:  force-postname-permalinks
Description:  Force permalinks to post-name. This will make the rest-api work out of the box.
Version:      1.0.0
Author:       Ru Nacken
Author URI:   https://github.com/rnacken
License:      MIT License
*/

add_action( 'init', function() {
    if (get_option('permalink_structure') == '') {
        global $wp_rewrite;
        $wp_rewrite->set_permalink_structure('/%postname%/');
    }
} );

After that, it worked.