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'
            ) );
Mazolo
  • 307
  • 4
  • 19

1 Answers1

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'
));

});

Almeida
  • 1,254
  • 12
  • 26