以下官方Shopify API的例子,我已經創建瞭如下要求更新庫存:Shopify API更新清查結果的「必需的參數丟失或無效」
[method] => PUT
[url] => https://<withheld>:<withheld>@test-shop-422.myshopify.com/admin/variants/1234567890.json
[headers] => Array (
[0] => Accept: application/json
[1] => Content-Type: application/json
[2] => X-HTTP-Method-Override: PUT
)
[params] => {"variant":{"id":1234567890,"inventory_quantity":2,"old_inventory_quantity":1}}
[response] => {"errors":{"variant":"Required parameter missing or invalid"}}
在論壇上,我發現這個答案,但它沒有幫助:https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/what-does-errors-variant-required-parameter-missing-or-invalid-mean-270461
我在做什麼錯?
謝謝。
編輯:這裏的最終請求CURL OPTS和原始響應(< ...> - 版主):
Array
(
[CURLOPT_AUTOREFERER] => 1
[CURLOPT_CAINFO] => <...>/cacert.pem
[CURLOPT_CONNECTTIMEOUT] => 5
[CURLOPT_FOLLOWLOCATION] => 1
[CURLOPT_HEADER] => 1
[CURLOPT_HTTPHEADER] => Array
(
[0] => Accept: application/json
[1] => Content-Type: application/json
[2] => X-HTTP-Method-Override: PUT
[3] => Expect:
[4] => Referer: <...>/process_queue
[5] => Content-Length: 47
)
[CURLOPT_MAXREDIRS] => 10
[CURLOPT_POSTFIELDS] => {"variant":{"inventory_quantity_adjustment":1}}
[CURLOPT_PUT] => 1
[CURLOPT_RETURNTRANSFER] => 1
[CURLOPT_SSL_VERIFYHOST] => 2
[CURLOPT_SSL_VERIFYPEER] => 1
[CURLOPT_TIMEOUT] => 5
[CURLOPT_URL] => https://<...>:<...>@test-shop-422.myshopify.com/admin/variants/26020635016.json
[CURLOPT_USERAGENT] => Mozilla/5.0
)
原始響應:
HTTP/1.1 400 Bad Request
Server: nginx
Date: Wed, 12 Oct 2016 01:23:05 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Frame-Options: DENY
X-ShopId: 9690230
X-ShardId: 7
X-Shopify-Shop-Api-Call-Limit: 1/40
HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT: 1/40
X-Stats-UserId: 0
X-Stats-ApiClientId: 1444946
X-Stats-ApiPermissionId: 31937062
X-XSS-Protection: 1; mode=block; report=/xss-report/<...>?source%5Baction%5D=update&source%5Bcontroller%5D=admin%2Fproduct_variants&source%5Bsection%5D=admin
X-Request-Id: <...>
X-Dc: chi2
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
X-Content-Type-Options: nosniff
{"errors":{"variant":"Required parameter missing or invalid"}}
嘗試'inventory_quantity_adjustment'而不是您正在使用的兩個庫存字段。 – HymnZ
@HymnZ:謝謝,沒有幫助...更新了帖子,以顯示原始選項和回覆 – Unirgy