2

Passing url as parameter results in error as below: {"code":"rest_no_route","message":"No route was found matching the URL and request method","data":{"status":404}}

How is this done in WP API?

register_rest_route( 'myap/v1', 'operation1/(?P<website>[regex for wesite here])',array( 'methods' => 'GET', 'callback' => 'myCallback' ) ); 

1 Answer 1

1

It is very simple, see an example for email:

add_action( 'rest_api_init', function () { register_rest_route( 'myap/v1', '/email/(?P<email>\S+)', array( 'methods' => 'GET', 'callback' => 'myCallback' )); 

});

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.