Custom Endpoint 404
-
I’m using Beta 10, PHP 7 on localhost with MAMP
My permalinks are set to postname.
The standard endpoints users, posts, etc are working correctly.
I’ve added these two functions in order to get a list of the post ids through the endpoint ‘/post-ids’
I get the response returned:
{
“code”: “rest_no_route”,
“message”: “No route was found matching the URL and request method”,
“data”: {
“status”: 404
}
}When I look at my namespaces I see my custom name space. I feel I’m close, but missing something small.
public function register_routes() { $version = '1'; $namespace = 'wpapi-testing/v' . $version; $base = 'post-ids'; register_rest_route( $namespace, '/' . $base, array( 'methods' => 'GET', 'callback' => 'my_awesome_func' ) ); } function my_awesome_func() { $all_post_ids = get_posts( array( 'numberposts' => -1, 'post_type' => 'post', 'fields' => 'ids', )); return $all_post_ids; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Custom Endpoint 404’ is closed to new replies.