首页 > 解决方案 > Magento 2.1 - 无法通过 REST 更新客户自定义属性

问题描述

我正在尝试更新客户中的自定义属性

但是 PUT 请求不起作用...

{
"customer":{
    "id":111,
    "group_id": 1,
    "email":"abcd@com",
    "firstname": "first",
    "lastname": "last",
    "taxvat": "123456789",
    "website_id": 1
},
"custom_attributes": 
[
    {
        "attribute_code": "customer_erp_id",
        "value": "66666"
    }       
]

}

端点 ..../rest/V1/customers/111

有一个现有的帖子Magento 2 REST API Customer Custom Attribute 似乎得出的结论是这是不可能的

因为它有点老了,我在徘徊,如果有人能够让这个工作......谢谢

标签: restmagentocustomercustom-attribute

解决方案


我遇到了同样的问题,但我只需更改主体内的 custom_attributes 节点即可轻松解决。

{
"customer": {
    "email":"roberto@test.com.mx",
    "firstname":"Roberto Carlos",
    "lastname":"Castillo",
    "storeId": 1,
    "websiteId":1,
    "gender":"1",
    "custom_attributes" : [
            {"attribute_code" : "foo", "value" : "bar" }
    ]
},
"password":"Test12345"

}


推荐阅读