Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento 2 REST API客户自定义属性_Rest_Api_Magento_Magento2 - Fatal编程技术网

Magento 2 REST API客户自定义属性

Magento 2 REST API客户自定义属性,rest,api,magento,magento2,Rest,Api,Magento,Magento2,Magento 2 REST API文档解释了在更新或创建客户时设置客户自定义_属性的方法 不幸的是,我没能让它工作 我的POST和PUT JSON请求数据是: { "customer": { "custom_attributes": [ { "attribute_code": "firstname", "value": "TEST" } ],

Magento 2 REST API文档解释了在更新或创建客户时设置客户自定义_属性的方法

不幸的是,我没能让它工作

我的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线程--提供了有关如何设置自定义客户属性的附加信息。

我对一个项目和属性“description”做了完全相同的操作,它确实起作用。为什么这对客户不起作用?我在Magento 2代码中找不到处理此请求的位置,也许您可以向我提供位置?-查看定义的WebAPI(
Magento\Customer\etc\WebAPI.xml
)对于所讨论的方法,
POST/V1/customers
API调用由
Magento\Customer\API\AccountManagementInterface::createAccount()
-根据di.xml(
Magento\Customer\etc\di.xml
)处理
Magento\Customer\Api\AccountManagementInterface
Magento\Customer\Model\AccountManagement
Magento\Customer\Model\AccountManagement.php
)实现-我建议使用Xdebug逐步查看代码,找出属性不更新的方式/原因。感谢您在@Sharath Kumar找到答案。我的结论是:这是不可能的,而且Magento 2对Customer API上的自定义_属性没有任何作用。与产品API不同。我想知道为什么文件上说你可以。。。