1

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@gmail.com","firstname":"first","lastname":"last","storeId":1,"websiteId":1}}"

The error thrown is {"message":"Decoding error."}

2 Answers 2

0

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@gmail.com","firstname":"first","lastname":"last","storeId":1,"websiteId":1}}'
1
  • I tried with single quotes as well..but still the same error..
    – user56395
    Jul 11, 2017 at 13:22
0

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": "test@gmail.com","firstname": "FirstName","lastname": "LastName","storeId": 1,"websiteId": 1}}'

let me know if have issue.

8
  • 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": "test@gmail.mobi","firstname": "FirstName","lastname": "LastName","storeId": 1,"websiteId": 1}}'
    – user56395
    Jul 12, 2017 at 4:57
  • are using any required custom attribute for customer.. and post your full error 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 2
    – user56395
    Jul 12, 2017 at 5:07
  • no am not using any custom attributes for customer..
    – user56395
    Jul 12, 2017 at 5:09
  • i update the answer, try that, let me know if you have issue. Jul 12, 2017 at 6:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.