1

我正在尝试为通过 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"
      }
    ]
  }
}
4

2 回答 2

2

Sku 是一个文本字段,您提交的是一个整数。切换它将为您修复它,我们将在我们这边修复它,以便您可以提交任何一个。

于 2012-09-22T15:30:44.400 回答
0

服务器返回“ 500 Internal Server Error ”,因此这不是您的客户端代码中的错误,如果您无权访问处理您的呼叫的服务器代码(myshop.myshopify.com ),则需要在服务器中进行调试/admin/products.json)然后您必须向该服务的管理员或支持团队提出问题,以便他们查看问题所在。

您的POST数据中的参数可能会导致错误,但如果不查看服务器代码,就无法准确找出问题所在。

于 2012-09-22T10:20:30.017 回答