我正在尝试为通过 shopify_api gem 与 Shopify 交互的 Rails 应用程序生成一些测试数据。我在 OS X 机器上使用 curl(命令行实用程序)。我不断从 Shopify 收到错误 500(见下文)。我束手无策,因为我看不出我做错了什么。任何帮助将不胜感激。
* About to connect() to [edited out].myshopify.com port 80 (#0)
* Trying 204.93.213.44...
* connected
* Connected to [edited out].myshopify.com (204.93.213.44) port 80 (#0)
* Server auth using Basic with user '[edited out]'
> POST /admin/products.json HTTP/1.1
> Authorization: Basic [edited out]
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: [edited out].myshopify.com
> Accept: */*
> Content-Type: application/json
> Content-Length: 694
>
* upload completely sent off: 694 out of 694 bytes
< HTTP/1.1 500 Internal Server Error
< Server: nginx
< Date: Sat, 22 Sep 2012 10:06:22 GMT
< Content-Type: application/json; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Status: 500 Internal Server Error
< X-Shopify-Shop-Api-Call-Limit: 1/500
< HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT: 1/500
< Cache-Control: no-cache
< X-Request-Id: 3a03a70617be67e89ab103a9b8053da9
< X-UA-Compatible: IE=Edge,chrome=1
< X-Runtime: 1.566916
<
* Connection #0 to host [edited out].myshopify.com left intact
{"errors":"Error"}* Closing connection #0
这就是我调用 curl 的方式:
curl -v -X POST -d @ss12-absolute.json -H 'Content-Type: application/json' http://some_key:some_password@myshop.myshopify.com/admin/products.json
POST 的数据文件如下所示:
{
"product": {
"title": "absolute",
"handle": "ss12-absolute",
"vendor": "deNada",
"product_type": "top",
"tags": "top,ss12,knits,casual,sleeveless",
"body_html": "",
"variants": [
{
"title": "absolute 08 eggplant",
"sku": 555647,
"price": "245.0",
"compare_at_price": "245.0",
"option1": "eggplant",
"option2": "08",
"option3": null
}
],
"options": [
{
"name": "Colour"
},
{
"name": "Size"
}
],
"metafields": [
{
"namespace": "retail_pro",
"key": "rp_style_sid",
"value": -5642228920827310084,
"value_type": "integer"
}
]
}
}