I have some API endpoints.
For example:
add_action('rest_api_init', function () {
register_rest_route(MY_APP_NAMESPACE, '/init', array(
'methods' => 'GET',
'callback' => function (WP_REST_Request $request) {
return get_current_user_id();
}
));
}
I am trying to test this endpoint with Postman.
I have generated 'X-WP-Nonce' with my localized script. And I am taking the nonce code from the browser console, and passing it through postman Headers.
But I am getting
{
"code": "rest_cookie_invalid_nonce",
"message": "Cookie nonce is invalid",
"data": {
"status": 403
}
}
But when I am trying with Ajax, in the same WordPress environment its works fine.
I think this is happening because the nonce is generated in a different session, so with another client, it can't respond.
My question is how can I test my API's with postman?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745279030a4620188.html
评论列表(0条)