0

I'm trying to update an attribute for a customer using the rest API
Being that I have a customer id, it should be a simple API call to /V1/customers/{id} The description of that endpoint is Create or update a customer.

However when I run something like this

curl -X PUT "https://magento2-example.com/index.php/rest/all/V1/customers/8" -H "accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer ********************************" -d "{ \"customer\": { \"middlename\": \"Junior\", }}"

I get an error that the The customer email is missing. Enter and try again.

If I add the customer's email, I get an error that A customer with the same email address already exists in an associated website.

I'm just wondering what's the point of the endpoint with the customer ID if to update the customer record you must pass in all of the following along with the data we're trying to update

{
  "id": "string",
  "email": "string",
  "firstname": "string",
  "lastname": "string",
  "store_id": "string",
  "website_id": "string",
}

Or if there's a better way to update a single attribute value for a customer knowing only the customer's ID.
I know we can fist GET the necessary customer info using a GET request with the customer ID but I'm just wondering if this is really Magento expected behavior?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.