Question

Rest API for updating customer PUT method not working. Every time creating new customer.

Method: PUT

Request URL: http://localhost/magento/rest/en/V1/customers/55

Body:

{
   "customer": {
     "email": "test@gmail.com",
     "firstname": "firstname new",
     "lastname":  "lastname new",
     "website_id": 1
   }
}

Also when pass the customer Email Id then response is throwing below error.

Response:

{
    "message": "A customer with the same email address already exists in an associated website."
}

Github Issue URL: https://github.com/magento/magento2/issues/24625

Was it helpful?

Solution

Request URL: http://localhost/magento/rest/en/V1/customers/55

Body :

{
   "customer": {
     "id":55,
     "email": "test@gmail.com",
     "firstname": "firstname new",
     "lastname":  "lastname new",
     "website_id": 1
   }
}

Add here ID field to update existing customer, also add all required fiels in payload.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top