Php Magento Api Rest Create Client Password Problem:

I am using Magento ver. 2.1.2 Rest Api to create users following this: 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); 

If I send a password (as in the example above), I have the following error:

 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 

I noticed that if I remove the "password" => "password" from the $ data array, the user will be created without a password (it seems strange to me).

I can not find help on this error. Somebody knows?

+6
source share
1 answer

See the link for Magento 2.x. http://devdocs.magento.com/swagger/index_20.html#/

I used the body below to create clients through Rest Api, and it worked correctly.

{ "customer": {

"email": " xyz@abc.com ", "firstname": "x", "lastname": "y", "Website_id": 1, "Group_id": 1, "custom_attributes": [{"attribute_code": " mobile_no "," value ":" 1234567890 "}]

},

"password": "123456"

}

+2
source

Source: https://habr.com/ru/post/1012541/


All Articles