Magento2: Cannot PUT (update) customer using REST api

Created on 20 Jun 2016  路  6Comments  路  Source: magento/magento2

It boils down to this: you cannot update a customer using the rest api using the latest RC.

Steps to reproduce

  1. Install Magento 2.1.0 latest RC using Composer
  2. Create a customer in admin. Note the customer entity id.
  3. PUT to the rest api using this URL: www.hostname.com/rest/V1/customers/entityIdFromAbove
{
    "customer": {
        "firstname": "Myfirstname",
        "lastname": "Mylastname"
    }
}

Expected result

  1. Customer Result JSON containing the updated values

    Actual result

 {
  "message": "Please enter a customer email.",
  "trace": "#0 /var/www/vendor/magento/module-eav/Model/Entity/VersionControl/AbstractEntity.php(90): Magento\\Customer\\Model\\ResourceModel\\Customer->_beforeSave(Object(Magento\\Customer\\Model\\Customer))\n#1 [internal function]: Magento\\Eav\\Model\\Entity\\VersionControl\\AbstractEntity->save... long stack trace

IF I include a customer email, it insists that i include the website_id as well, which at that point it is attempting to create a new customer. (I've stepped through the code).

If this bug is able to be reproduced by ANYONE, I'll go ahead and really flesh out this ticket with more details.

Format is not valid

All 6 comments

I have noticed that the $customerModel->save() on line https://github.com/magento/magento2/blob/develop/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php#L193 does not take into consideration any preexisting data. This data is already available from line 141 above as $prevCustomerData.

The customerModel->save() attempts a full validation on the customer, and since the rest api call is only specified that you send in the changes you want to have happen to the object, it reports missing things like email and website ID inside of customer\Model\ResourceMode\Customer.php on lines 103+

Reinstalled magento. Seems to work ok.

I am having this same issue on 2.1.7

Hi, mitcht.
Could you please explain the solution of that issue?
I met that issue on Magento 2.1.7 and 2.1.9.
a:4:{i:0;s:30:"Please enter a customer email.";i:1;s:16296:"#0 ...

Is there a reason this is closed? I still cannot find a customer update endpoint with self permissions.

This issue is still there on Magento EE2.1.19, Before that, I updated Magento from version EE2.1.6.
API always returns
"message": "Please enter a customer email.",
when I want to update customer information.

As I known, All info from the Request are used in $inputData in vendor/magento/module-webapi/Controller/Rest/InputParamsResolver.php:100

but the value that Magento returns is $inputParams, This one does not consist of data from API request.

Was this page helpful?
0 / 5 - 0 ratings