2017-01-13 183 views
0

嘗試通過cURL創建一個虛擬訂單時,我收到此錯誤。我試圖通過郵政總監創建訂單。我只是從woocommerrce documentation複製代碼,但還是錯誤是正在添加 代碼WooCommerce返回錯誤

curl -X POST -H "Content-Type: application/javascript" -H "Cache-Control: no-cache" -H "Postman-Token: 56032927-8d69-3630-aae9-0eb6823fe9b0" -d '{ 
     "payment_method": "cod", 
     "payment_method_title": "Cash on Delivery", 
     "set_paid": true, 
     "billing": { 
     "first_name": "bhbhub", 
     "last_name": "Dnuoe", 
     "address_1": "969 Market", 
     "address_2": "", 
     "city": "beach", 
     "state": "Goa", 
     "postcode": "122002", 
     "country": "India", 
     "email": "[email protected]", 
     "phone": "1234567890" 
     }, 
     "shipping": { 
     "first_name": "John", 
     "last_name": "Doe", 
     "address_1": "969 Market", 
     "address_2": "", 
     "city": "beach", 
     "state": "Goa", 
     "postcode": "94103", 
     "country": "US" 
     }, 
     "line_items": [ 
     { 
      "product_id": 100, 
      "quantity": 2 
     } 

     ], 
     "shipping_lines": [ 
     { 
      "method_id": "flat_rate", 
      "method_title": "Flat Rate" 


     } 
     ] 
    }' "http://www.jersershor.com/wc-api/v3/orders?oauth_consumer_key=ck_638caaf46271a320075ecee01e89581f91644b98&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1484290102&oauth_nonce=cwidKMBu2uE&oauth_version=1.0&oauth_signature=VUMuuVRXsXKvyFhk97dQWj5bCEI%3D 
" 
+2

歡迎來到Stackoverflow!爲了充分利用網站,提出一些好問題很重要。有關提問的指南,請訪問:http://stackoverflow.com/help/how-to-ask –

回答

0

的問題是與woocommerce的文檔

需要來包裝你的請求主體的JSON在order對象開始。所以它會像{ 「序」:{...以上的數據}}

所以身體的代碼將

{ 「序」:{

"status": "processing", 

    "payment_details": { 
     "method_id": "bacs", 
     "method_title": "Direct Bank Transfer", 
     "paid": true 

    }, 

    "billing_address": { 
     "first_name": "bhbhub", 
     "last_name": "Dnuoe", 
     "address_1": "969 Market", 
     "address_2": "", 
     "city": "beach", 
     "state": "Goa", 
     "postcode": "122002", 
     "country": "IN", 
     "email": "[email protected]", 
     "phone": "1234567890" 
    }, 
    "shipping_address": { 
     "first_name": "John", 
     "last_name": "Doe", 
     "address_1": "969 Market", 
     "address_2": "", 
     "city": "beach", 
     "state": "Goa", 
     "postcode": "94103", 
     "country": "IN" 
    }, 
    "line_items": [{ 
      "product_id": 100, 
      "quantity": 2 
     } 

    ], 
    "customer": { 
     "id": 0, 
     "total_spent": "320", 
     "email": "[email protected]", 
     "first_name": "bhbhub", 
     "last_name": "Dnuoe", 
     "billing_address": { 
      "first_name": "bhbhub", 
      "last_name": "Dnuoe", 
      "company": "", 
      "address_1": "969 Market", 
      "address_2": "", 
      "city": "beach", 
      "state": "Goa", 
      "postcode": "122002", 
      "country": "IN", 
      "email": "[email protected]", 
      "phone": "1234567890" 
     }, 
     "shipping_address": { 
      "first_name": "John", 
      "last_name": "Doe", 
      "company": "", 
      "address_1": "969 Market", 
      "address_2": "", 
      "city": "beach", 
      "state": "Goa", 
      "postcode": "94103", 
      "country": "IN" 
     } 
    } 
} 

}