【问题标题】:Magento Rest API - Add Customer addressMagento Rest API - 添加客户地址
【发布时间】:2016-08-19 08:01:51
【问题描述】:

除了 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"
      ]
    }
  }

如果上述请求有任何问题,请告知。

谢谢。

【问题讨论】:

    标签: json xml rest magento magento-1.9


    【解决方案1】:

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

    {
    "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"
      ]
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-30
      • 2018-02-25
      • 2023-03-06
      • 2012-08-16
      相关资源
      最近更新 更多