WordPress中的自定义POST路由?

时间:2019-08-15 11:59:15

标签: wordpress rest

我刚刚使用GET方法注册了一个自定义WordPress终结点,并且工作正常,但是如果我对POST做同样的事情,它将找不到路由。

我已经完全尝试了每个人所说的方法。 WP_REST_Server::CREATABLEPOSTpost。似乎没有一个起作用,这对我来说毫无意义,因为我认为GETPOST之间的区别不应该使一个起作用,而对其他却没有作用。

add_action( 'rest_api_init', function(){
    register_rest_route('x/v1/', 'x', array(
            'methods'  => WP_REST_Server::READABLE,
            'callback' => 'get_user_folder_id',
            )
    );
});
add_action( 'rest_api_init', function(){
    register_rest_route('x/v1/', 'x/', array(
          'methods'  => WP_REST_Server::CREATABLE,
          'callback' => 'post_user_folder_id',
          'show_in_rest' => true,
          )
      );
});

我希望在使用邮递员时找到路线,我只是在回声一个字符串。

我的答复是:

{
   "code": "rest_no_route",
   "message": "No route was found matching the URL and request method",
}

0 个答案:

没有答案