admin管理员组文章数量:1419250
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?
本文标签: ajaxTest WordPress api with postman
版权声明:本文标题:ajax - Test WordPress api with postman 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745279029a2651333.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论