2017-03-20 4 views
0

woocommerce 나머지 API에 문제가 있습니다. 나머지 API를 통해 사진이있는 제품을 만들고 싶지만 사진이 없으면 작동하지 않습니다.Woocommerce JSON API

이 코드 작업 조각 :

{ "REGULAR_PRICE": "21.99", "이름": "프리미엄 품질", "설명": "Pellentesque 주민 morbi tristique senectus 등 netus" "유형": "간단한" }

하지만이 작동하지 않습니다

{ "REGULAR_PRICE": "21.99", "이미지": "[{\"SRC \ "\" https://static01.nyt.com/images/2017/03/17/world/europe/oakImage-1489777706390/oakImage-1489777706390-largeHorizontal375.jpg \ ", \""설명": "Pellentesque habitant morbi tristique senectus etnetus", "type": "simple"(예 : 위치 \ ": 0, \"id \ ": 0}]" "이름" }

JSON의 유효성을 검사합니다. 서버로부터의 응답은 다음

{ "코드": "woocommerce_product_invalid_image_id" "메시지". "# 0가 유효 화상 ID는," "데이터"{ '상태'400 }}

답변

0

documentation :

콘텐츠 ID (첨부 ID). 쓰기 모드에서는 기존 이미지를 첨부하는 데 사용됩니다.

이에 따르면 이미지 개체에 id 매개 변수없이이 요청을 보내야합니다. id = 0 인 기존 이미지가 없기 때문입니다. 워드 프로세서에서 촬영

예제 코드 :

{ 
    name: 'Premium Quality', 
    type: 'simple', 
    regular_price: '21.99', 
    description: 'Pellentesque habitant morbi...', 
    short_descriptienter code hereon: 'Pellentesque ...', 
    categories: [ 
    { 
     id: 9 
    }, 
    { 
     id: 14 
    } 
    ], 
    images: [ 
    { 
     src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg', 
     position: 0 
    }, 
    { 
     src: 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg', 
     position: 1 
    } 
    ] 
}; 
관련 문제