- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2015
05:48 AM
12-30-2015
05:48 AM
Error when creating customer with ID using REST
Hi.
I'm trying to create a customer in Magento 2.0 via REST. But when I specify the ID I get an error. Creating customers and letting Magento set the ID works fine, but I want do deside what the customer ID should be. Is this really not possible? In Magento 1.9 this works btw.
This works:
POST:
{ "customer": { "email": "info@mail.com", "firstname": "myfirstname", "lastname": "mylastname" } }
Response is then: (Customer was created with ID nr 6)
<?xml version="1.0"?> <response> <id>6</id> <group_id>1</group_id> <created_at>2015-12-30 13:35:19</created_at> <updated_at>2015-12-30 13:35:19</updated_at> <created_in>Default Store View</created_in> <email>info@mail.com</email> <firstname>myfirstname</firstname> <lastname>mylastname</lastname> <store_id>1</store_id> <website_id>1</website_id> <addresses/> <disable_auto_group_change>0</disable_auto_group_change> </response>
But if I try to create the customer by setting the ID to 4711 I get the error:
{ "customer": { "id": "4711", "email": "info2@mail.com", "firstname": "myfirstname2", "lastname": "mylastname2" } }
Response is then:
<?xml version="1.0"?> <response> <message>No such entity with %fieldName = %fieldValue, %field2Name = %field2Value</message> <parameters> <fieldName>email</fieldName> <fieldValue>info2@mail.com</fieldValue> <field2Name>websiteId</field2Name> <field2Value>1</field2Value> </parameters> </response>
I tried without "" but same error:
{ "customer": { "id": 4711, "email": "info2@mail.com", "firstname": "myfirstname2", "lastname": "mylastname2" } }
PS I use RESTClient in Firefox.
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2017
01:07 PM
04-08-2017
01:07 PM
Re: Error when creating customer with ID using REST
This is an old post, but you don't add the id when you are creating a customer.
This value will be generated for you and delivered to you in the response.
btw: I am still using 1.9x.