gpt4 book ai didi

Php Magento Api Rest 创建客户密码问题 :

转载 作者:可可西里 更新时间:2023-11-01 13:27:30 24 4
gpt4 key购买 nike

我使用的是 Magento 版本。 2.1.2 Rest Api 创建用户,如下: http://devdocs.magento.com/guides/m1x/api/rest/Resources/resource_customers.html#RESTAPI-Resource-Customers-HTTPMethod-POST-customers

$data = [
"customer" => [
"firstname" => 'Earl',
"lastname" => 'Hickey',
"email" => 'earl-2@example.com',
"password" => 'password',
"website_id" => 1,
'store_id' => 1,
"group_id" => 1
]
];

$token = $this->get('lp_api')->getToken();
$ch = curl_init( $this->endpoint . 'customers');

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json", "Authorization: Bearer " . json_decode( $token ),
)
);

// var_dump(curl_getinfo($c));
$result = curl_exec($ch);

如果我发送密码(如上例所示),则会出现以下错误:

Next Exception: Report ID: webapi-583357a3bf02f; Message: Property "Password" does not have corresponding setter in class "Magento\Customer\Api\Data\CustomerInterface". in /var/www/html/www.magento.dev/vendor/magento/framework/Webapi/ErrorProcessor.php:195

我注意到如果我从 $data 数组中删除 "password"=> 'password',将创建一个没有密码的用户(对我来说似乎很奇怪)。

我找不到关于此错误的任何帮助。有什么想法吗?

最佳答案

请参阅以下链接了解 Magento 2.x 版本。 http://devdocs.magento.com/swagger/index_20.html#/

我已经使用下面的正文通过 Rest Api 创建客户并且它工作正常。

{“客户”:{

"邮箱": "xyz@abc.com", “名字”:“x”, “姓氏”:"is", “website_id”:1, “group_id”:1, “自定义属性”:[ { "attribute_code": "mobile_no", “值”:“1234567890” }]

},

“密码”:“123456”

关于Php Magento Api Rest 创建客户密码问题 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40728846/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com