我正在尝试为我的Rails应用程序生成一些测试数据,该应用程序通过shopify_api gem与Shopify连接。我在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
POSTed数据文件如下所示:
{
"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"
}
]
}
}
答案 0 :(得分:2)
Sku是一个文本字段,您提交的是一个整数。切换将为您修复它,我们将在我们的最后修复它,以便您可以提交。
答案 1 :(得分:0)
服务器返回“ 500内部服务器错误”,因此在客户端代码中不是错误,如果您无法访问服务器代码,则需要在服务器中进行验证处理你的电话( myshop.myshopify.com/admin/products.json )然后你必须向该服务的管理员或支持团队打开一个问题,以便他们看看有什么问题。< / p>
POST 数据中的参数可能会导致错误,但如果不查看服务器代码,就无法确切地知道错误。