[wp-trac] [WordPress Trac] #46160: No route was found matching the URL and request method
WordPress Trac
noreply at wordpress.org
Fri Feb 1 00:19:58 UTC 2019
#46160: No route was found matching the URL and request method
----------------------------+--------------------------------------
Reporter: RogueWebDesign | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: critical | Keywords: needs-patch dev-feedback
Focuses: |
----------------------------+--------------------------------------
Since WordPress version 5.0.3, it seems the "register_rest_route" function
is no longer working as expected.
All custom endpoints are now returning:
code: "rest_no_route",
message: "No route was found matching the URL and request method",
Previously, our endpoints were working without issue. Here is an example
of our rest_api_ini action:
{{{#!php
<?php
function register_our_custom_api_routes() {
register_rest_route( 'custom-namespace/v1', '/endpointtest', array(
'methods' => 'POST',
'callback' => 'our_custom_callback_function',
)
);
function our_custom_callback_function() {
/* Do Things */
}
}
add_action( 'rest_api_init', 'register_our_custom_api_routes' );
}}}
We have tested this on multiple installs with all plugins disabled and
using the Twenty Nineteen theme. The namespace shows up with all the
endpoints at:
{testdomain}/wp-json/custom-namespace/v1
However, trying to access {testdomain}/wp-json/custom-
namespace/v1/endpointtest returns the error "rest_no_route".
Note: the above example has been adjusted for security purposes.
The issue is occurring across all WordPress sites we have checked.
Thanks :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46160>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list