PHP Notice: register_rest_route was called incorrectly. The REST API route definition for relevanssi/v1/search is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information.
PHP error after WordPress 5.5 update
My wordpress custom api plugin : “register_rest_route was called incorrectly.” error on WordPress 5.5 RC2 & namespace must not start or end with a slash.
I’m getting the following error in the wp-admin area after updating to WordPress 5.5 (note: I have wp_debug turned ON): register route in wordpress.
Notice: register_rest_route was called incorrectly. The REST API route definition for mc4wp/v1/form is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /public_html/wp-includes/functions.php on line 5225
Notice : register_rest_route was called incorrectly . The REST API route definition for test/productsis missing a permission_callbackrequired argument . For REST API routes that are public, use __return_trueas the permission callback. Read how to debug WordPress for more information. (This message was added in version 5.5.0.) In /Users/test/www/wordpress/wp-includes/functions.php on line 5225
Notice : register_rest_route was called incorrectly . The REST API route definition for is missing a required argument . For REST API routes that are public, use as the permission callback. Read howtest/products/(?P[\d]+)permission_callback__return_trueDebug WordPress for more information. (This message was added in version 5.5.0.) In /Users/test/www/wordpress/wp-includes/functions.php on line 5225
Notice : register_rest_route was called incorrectly . The REST API route definition for is missing a required argument . For REST API routes that are public, use as the permission callback. Read how to debug WordPress for more information. (This message was added in version 5.5.0.) In /Users/test/www/wordpress/wp-includes/functions.php on line 5225 Notice : register_rest_route was called incorrectlytest/products/(?P[\d]+)/variationspermission_callback__return_true
rest_api_init not working
. The REST API route definition for is missing a required argument . For REST API routes that are public, use as the permission callback. Read how to debug WordPress for more information. (This message was added in version 5.5.0.) In /Users/test/www/wordpress/wp-includes/functions.php on line 5225 Notice : register_rest_route was called incorrectly . The REST API route definition for is missing a required argument . For REST API routes that are public, use as the permission callback. Read how to debug WordPresstest/products/(?P[\d]+)/variations/(?P[\d]+)permission_callback__return_true
test/products/categoriespermission_callback__return_truefor more information. (This message was added in version 5.5.0.) In /Users/test/www/wordpress/wp-includes/functions.php on line 5225
Notice : register_rest_route was called incorrectly . The REST API route definition for is missing a required argument . For REST API routes that are public, use as the permission callback. Read how to debug WordPress for more information. (This message was added in version 5.5.0.) In /Users/test/www/wordpress/wp-includes/functions.php on line 5225 Notice : register_rest_route was called incorrectlytest/products/categories/(?P[\d]+)permission_callback__return_true
. The REST API route definition for test/products/tagsis missing a permission_callbackrequired argument . For REST API routes that are public, use __return_trueas the permission callback. Read how to debug WordPress for more information. (This message was added in version 5.5.0.) In /Users/test/www/wordpress/wp-includes/functions.php on line 5225
Notice : register_rest_route was called incorrectly . The REST API route definition for is missing a required argument . For REST API routes that are public, use as the permission callback. Read how to debug WordPresstest/products/tags/(?P[\d]+)permission_callback__return_truefor more information. (This message was added in version 5.5.0.) In /Users/test/www/wordpress/wp-includes/functions.php on line 5225
Notice : register_rest_route was called incorrectly . The REST API route definition for test/products/reviewsis missing a permission_callbackrequired argument . For REST API routes that are public, use __return_trueas the permission callback. Read how to debug WordPress for more information. (This message was added in version 5.5.0.) In /Users/test/www/wordpress/wp-includes/functions.php on line 5225
Notice : register_rest_route was called incorrectly. The REST API route definition for is missing a required argument . For REST API routes that are public, use as the permission callback. Read how to debug WordPress for more information. (This message was added in version 5.5.0.) In /Users/test/www/wordpress/wp-includes/functions.php on line 5225 Notice : register_rest_route was called incorrectly . The REST API route definition for is missing a required argument . For REST API routes that are public, use as the permission callback. Read how to debug WordPresstest/products/reviews/(?P[\d]+)permission_callback__return_true
public-woo/v1/settingspermission_callback__return_truefor more information. (This message was added in version 5.5.0.) In /Users/test/www/wordpress/wp-includes/functions.php on line 5225
REST API ERRORS
I just updated the Gist to add the permission_callback.
'permission_callback' => '__return_true',
Also Read: FIX 500 internal server error
rest-api-endpoint.php
here simple example for register_rest_route post method.
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly class WP_YOUR_CLASS_NAME_Rest_Controller extends WP_REST_Controller { public function callHooks(){ add_action( 'rest_api_init', array($this,'registerApiEndpoints') ); } function registerApiEndpoints() { register_rest_route( 'public-woo/v3', '/settings', array( 'methods' => 'POST', 'callback' => array($this,'resetApiAllOptions'), 'permission_callback' => '__return_true', //I just updated the Gist to add the permission_callback. ) ); } public function resetApiAllOptions(){ global $wpdb; $resultsData = array( "error" => 0, "message" => "Sorry, you are not allowed to edit this resource.", "code" => "woocommerce_rest_cannot_edit" ); return json_encode($resultsData); } }
How to Fix Common WooCommerce REST API Issues?
woocommerce_rest_cannot_view, Sorry, you cannot list resources, 401 or “error_message”: “Sorry, you cannot list resources.” using WooCommerce API
{ "code": "woocommerce_rest_cannot_view", "message": "Sorry, you cannot list resources.", "data": { "status": 401 } }
In register_rest_route authentication, Please review the documentation here: woocommerce rest api docs