Woocommerce休息api自定义路由不能在javascript中工作

时间:2016-12-06 06:58:31

标签: javascript wordpress woocommerce-rest-api wordpress-rest-api

我已经为woocommerce rest api注册了新的自定义路线,使用下面的代码

const Product_Review = 'products/reviews/(?P<product_id>[\d]+)';
public function register_routes( $routes ) {
    $routes[ self::Product_Review ] = array(array(
        array( $this, 'create_product_review_item' ),
        WC_API_Server::EDITABLE | WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA 
    ));
    return $routes;
}

此路线已成功注册,因为我可以在这样的woocommerce端点中看到它:

enter image description here

但是当我从javascript调用此api时,它会给我这个错误:

{
    "errors":[
        {
            "code":"woocommerce_api_no_route",
            "message":"No route was found matching the URL and request method"
        }
    ]
}

我的网址:

http://angular.templatic.net/wc-api/v3/products/reviews/31?oauth_consumer_key=ck_9ae878f7a1fa134a2acad1eef7c0182dd3f7e68a&oauth_nonce=d3gf9k8KQXrzGV3LTugcVqrrdME6wzCz&oauth_signature_method=HMAC-SHA256&oauth_timestamp=1481008886&oauth_version=1.0&oauth_signature=xahKi7PjaLxEUaJWPTUnewbI0JoJKYi2Vtn3L2KF1%2FM%3D

我想在db。中插入数据的post方法使用此路由。

0 个答案:

没有答案
相关问题