Pass String Parameters to WP REST API
I found it myself...
use [a-zA-Z0-9-]
instead of \d
for strings
add_action( 'rest_api_init', function () { register_rest_route( 'crowdapi/v1', '/register/(?P<id>\d+)/(?P<number>[a-zA-Z0-9-]+)', array( 'methods' => 'POST', 'callback' => 'userCheck', ) );} );
Try below code for define endpoint as well..
add_action( 'rest_api_init', function () { register_rest_route( 'crowdapi/v1', '/register/(?P<id>\d)/(?P<username>\d)', array( 'methods' => 'POST', 'callback' => 'userCheck', ) );} );