Wordpress REST API custom endpoint for method POST Wordpress REST API custom endpoint for method POST wordpress wordpress

Wordpress REST API custom endpoint for method POST


Finally found it! In order to access the body of the POST request use $request->get_body(); in your register_rest_route callback method.


in your callback function you can use something like this:

 $param = $request->get_param( 'some_param' );  // You can get the combined, merged set of parameters: $parameters = $request->get_params();

https://www.coditty.com/code/wordpress-api-custom-route-access-post-parameters


Add POST in methods while registering route and in your callback function access your POST variables via $request array. That's it.