Magento Rest API - 添加客户地址

时间:2016-08-19 08:01:51

标签: json xml rest magento magento-1.9

除了 POST / customers /:customer_id / addresses 之外,大部分Magento rest api方法都适用于我。

我收到以下错误:

    <error>
      <data_item>
        <code>400</code>
        <message>"Street Address" is a required value.</message>
      </data_item>
      <data_item>
        <code>400</code>
        <message>Resource data pre-validation error.</message>
      </data_item>
    </error>

错误很清楚,说地址线丢失但我在json请求中找不到任何错误。我刚刚将他们的文档中的示例XML请求数据转换为json并在请求正文中提交。

http://devdocs.magento.com/guides/m1x/api/rest/Resources/resource_customer_addresses.html#RESTAPI-Resource-CustomerAddresses-HTTPMethod-POST-customers--customerid-addresses

这是我的json请求数据:

{
    "firstname": "Johny",
    "lastname": "Doe",
    "city": "PA",
    "region": "Palau",
    "postcode": "19103",
    "country_id": "US",
    "telephone": "611-634-1181",
    "street": {
      "data_item": [
        "2354 Jody Road Philadelphia",
        "844 Jefferson Street; 4510 Willis Avenue"
      ]
    }
  }

请告知上述请求中是否有任何错误。

感谢。

1 个答案:

答案 0 :(得分:0)

好的,这对我有用(也许他们的文档需要更新)。

{
"firstname": "Johny",
"lastname": "Doe",
"city": "PA",
"region": "Palau",
"postcode": "19103",
"country_id": "US",
"telephone": "611-634-1181",
"street": 
   [
    "2354 Jody Road Philadelphia",
    "844 Jefferson Street; 4510 Willis Avenue"
  ]

}