Custom Endpoint cant get params
-
using WP REST API Version 2.0-beta4
on WordPress 4.3.1I have registered an endpoint as
register_rest_route( $baseAPI, '/getByLetter/(?P<id>\w)', array( 'methods' => WP_REST_Server::READABLE, 'callback' => 'getByLetter' , 'args' => array( 'id' => array( 'required' => true ), )));
and defined the callback as
function getByLetter($a) { error_log(json_encode($a)); error_log(json_encode(debug_backtrace())); .....
The callback is happening and all working OK (well without argument !), but the log gives me
[30-Sep-2015 21:38:03 UTC] {}
(argument value)
[30-Sep-2015 21:38:03 UTC] [{“function”:”getByLetter”,”args”:[{}]} …….
(call stack)
in class-wp-rest-server.php (function dispatch) the arguments are being split out OK .. just after the match (*line 704)
$match = preg_match( '@^' . $route . '$@i', $path, $args );
I see $args as[30-Sep-2015 22:00:31 UTC] Args {“0″:”\/wp\/v2\/getByLetter\/C”,”id”:”C”,”1″:”C”}
anyone have any ideas ??
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Custom Endpoint cant get params’ is closed to new replies.