2016-07-27 5 views
2

나는 우체부를 사용하여 다음과 같은 WooCommerce 나머지의 API에 제품을 게시하려고 내가 상태 401 unauthorized에 응답 다음 얻고있다 대가로 우편 배달는 WooCommerce 나머지 API "woocommerce_rest_cannot_create"

var settings = { 
    "async": true, 
    "crossDomain": true, 
    "url": "http://woocommerce.dev/wp-json/wc/v1/products", 
    "method": "POST", 
    "headers": { 
    "content-type": "application/json", 
    "authorization": "OAuth oauth_consumer_key=\\\"ck_da643d25cb86d32dcf1c4a684ba0fdad4acd67ce\\\",oauth_signature_method=\\\"HMAC-SHA1\\\",oauth_timestamp=\\\"1469615598\\\",oauth_nonce=\\\"oOOqcB\\\",oauth_version=\\\"1.0\\\",oauth_signature=\\\"jf%2FepKymwW9IFlv7fwHFTA3aNs8%3D\\\"", 
    "cache-control": "no-cache", 
    "postman-token": "2202e03b-243e-96c5-8e77-fcc8919aedbc" 
    }, 
    "processData": false, 
    "data": "{\n \"name\": \"Premium Quality\",\n \"type\": \"simple\",\n \"regular_price\": \"21.99\",\n \"description\": \"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.\",\n \"short_description\": \"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\",\n \"categories\": [\n {\n  \"id\": 9\n },\n {\n  \"id\": 14\n }\n ],\n \"images\": [\n {\n  \"src\": \"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg\",\n  \"position\": 0\n },\n {\n  \"src\": \"http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg\",\n  \"position\": 1\n }\n ]\n}" 
} 

$.ajax(settings).done(function (response) { 
    console.log(response); 
}); 

를 사용 Javascript에서 생성 된 코드입니다

{ 
    "code": "woocommerce_rest_cannot_create", 
    "message": "Sorry, you are not allowed to create resources.", 
    "data": { 
    "status": 401 
    } 
} 

어디에서 성공적으로 모든 제품을 얻기 위해 같은 엔드 포인트에서 GET 방법으로 데이터를 얻을 수있는 동일한 자격 증명으로

,536,913 63,210

http://woocommerce.dev/wp-json/wc/v1/products

더욱 더 WooCommerce에

이미이에 대한 연구는 거의 2 박 후이 자격 증명

+0

해결책을 찾았습니까? 그렇다면 공유하십시오. 도움이 될 것입니다. – Madhan

답변