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
Solved! Go to Solution.
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"
}
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"
}