cancel
Showing results for 
Search instead for 
Did you mean: 

REST API PUT on /index.php/rest/V1/customers

SOLVED

REST API PUT on /index.php/rest/V1/customers

I'm having a problem using PUT through REST to create a new customer in my Magento 2 instance. I've got my 'authorization token' and can GET my customers through a request. It should work but I'm having an issue with the layout of my request's body, I think. Trying to include all the necessary fields - but keeps returning:

{
  "message": "%fieldName is a required field.",
  "parameters": {
    "fieldName": "customer"
  }
}

Could someone try and add a customer through this, and maybe provide an example of what the body of my request should look like. All help appreciated 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: REST API POST on /index.php/rest/V1/customers

Originally I meant to say POST here..

But the solution was just to POST the new customer but without the ID field - presumably because it likes to create that field itself. This works:

POST http://localhost/index.php/rest/V1/customers

Authorization       Bearer <access token goes here>
Content-Type      application/json

{
  "customer": {
    "email": "string",
    "firstname": "string",
    "lastname": "string"
  },
    "password": "string"
}

View solution in original post

1 REPLY 1

Re: REST API POST on /index.php/rest/V1/customers

Originally I meant to say POST here..

But the solution was just to POST the new customer but without the ID field - presumably because it likes to create that field itself. This works:

POST http://localhost/index.php/rest/V1/customers

Authorization       Bearer <access token goes here>
Content-Type      application/json

{
  "customer": {
    "email": "string",
    "firstname": "string",
    "lastname": "string"
  },
    "password": "string"
}