Problem on creating custom endpoints for REST

Writing a custom endpoint is not hard at all. Your code goes to your theme’s functions.php file, or a plugin. After you register a REST route, you can access it via this URL:

www.example.com/wp-json/myplugin/v1/foo

Also I assume you are missing \ in your callback function’s parameters, as it should be \WP_REST_Request $request.

tech