Magento 2 REST API 客户自定义属性

Magento 2 REST API Customer Custom Attribute

Magento 2 REST API 文档解释了一种在更新或创建客户时设置 custom_attributes 客户的方法。 http://devdocs.magento.com/swagger/index_20.html#/

不幸的是我无法让它工作...

我的 POST 和 PUT JSON 请求数据是:

{
    "customer": {
        "custom_attributes": [
            {
                "attribute_code": "firstname",
                "value": "TEST"
            }
        ],
        "email": "someone@exaxmple.com",
        "extension_attributes": [],
        "firstname": "Someone",
        "gender": null,
        "lastname": "Else",
        "middlename": null,
        "taxvat": null,
        "website_id": "1"
    }
}

客户已创建,但名字不是 "TEST"。 有没有人遇到同样的问题并解决了它?请告诉我怎么做。

我最好的猜测是,由于 Firstname 是现有的开箱即用属性 - OOTB 属性名称-值映射分配将优先。

您能否再试一次,使用唯一的自定义属性名称(即与 OOTB 属性名称不冲突的名称)

您需要先定义自定义客户属性,然后才能使用 M2 API 对该自定义客户属性执行操作。

此 StackExchange 线程 - https://magento.stackexchange.com/questions/88245/magento2-create-a-customer-custom-attribute - 提供了有关如何设置自定义客户属性的更多信息。