I am new to magento. I am facing an issue will trying to create customer using curl command. I am passing the correct json values as customer data as well, but still getting decoding error.Can some one please help!
This is the command that I am using for creating the customer:
curl -X POST "http://127.0.0.1/magento2/index.php/rest/V1/customers" -H "Authorization: Bearer pvcp6auic4likpucpi07peas89hxivhe" -H "Content-Type: application/json" -d "{"customer":{"email":[email protected]","firstname":"first","lastname":"last","storeId":1,"websiteId":1}}"
The error thrown is {"message":"Decoding error."}
2 Answers 2
You have to replace "(double quotes) with '(single quotes) at outer json data like below:
curl -X POST "http://127.0.0.1/magento2/index.php/rest/V1/customers" -H "Authorization: Bearer pvcp6auic4likpucpi07peas89hxivhe" -H "Content-Type: application/json" -d '{"customer":{"email":"[email protected]","firstname":"first","lastname":"last","storeId":1,"websiteId":1}}'
- 
 I tried with single quotes as well..but still the same error..user56395– user563952017年07月11日 13:22:11 +00:00Commented Jul 11, 2017 at 13:22
Try this code, its works for me,
 curl -X POST "http://localhost/magento2/index.php/rest/V1/customers" -H "Content-Type: application/json" -H "Authorization: Bearer xhfyo8cfvknpyd5dwuupe34uosh6tuhj" -d '{"customer": {"email": "[email protected]","firstname": "FirstName","lastname": "LastName","storeId": 1,"websiteId": 1}}'
let me know if have issue.
- 
 Thanks for the reply, I tried with the above command, still the same decoding error. :( The command that I used here is : curl -X POST "localhost/magento2/index.php/rest/V1/customers" -H "Content-Type: application/json" -H "Authorization: Bearer pvcp6auic4likpucpi07peas89hxivhe" -d '{"customer": {"email": "[email protected]","firstname": "FirstName","lastname": "LastName","storeId": 1,"websiteId": 1}}'user56395– user563952017年07月12日 04:57:38 +00:00Commented Jul 12, 2017 at 4:57
- 
 are using any required custom attribute for customer.. and post your full errorRajkumar Elumalai– Rajkumar Elumalai2017年07月12日 04:59:06 +00:00Commented Jul 12, 2017 at 4:59
- 
 The error here is curl: (3) [globbing] unmatched brace in column1 culr: (6) COuldn't resolve host 'gmail.com,firstname' curl:(6) couldn't resolve host "FirstName,lastname' curl: (6) couldn't resolve host 'LastName,storeId' curl: (6) couldn't resolve host '1,websiteId' curt: (3) [globbing] unmatched close brace/bracket in column 2user56395– user563952017年07月12日 05:07:35 +00:00Commented Jul 12, 2017 at 5:07
- 
 no am not using any custom attributes for customer..user56395– user563952017年07月12日 05:09:25 +00:00Commented Jul 12, 2017 at 5:09
- 
 i update the answer, try that, let me know if you have issue.Rajkumar Elumalai– Rajkumar Elumalai2017年07月12日 06:04:13 +00:00Commented Jul 12, 2017 at 6:04