0

Magento 2 how to pass data for the api PUT rest/V1/customers/me/ since we are getting issue below

{
    "message": "Please enter a customer email.",
    "trace": "#0 /var/www/html/magento2/vendor/magento/module-eav/Model/Entity/VersionControl/AbstractEntity.php(90): Magento\\Customer\\Model\\ResourceModel\\Customer->_beforeSave(Object(Magento\\Customer\\Model\\Customer\\Interceptor))\n#1 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Eav\\Model\\Entity\\VersionControl\\AbstractEntity->save(Object(Magento\\Customer\\Model\\Customer\\Interceptor))\n#2 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Customer\\Model\\ResourceModel\\Customer\\Interceptor->___callParent('save', Array)\n#3 /var/www/html/magento2/vendor/magento/framework/App/Cache/FlushCacheByTags.php(68): Magento\\Customer\\Model\\ResourceModel\\Customer\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Customer\\Model\\Customer\\Interceptor))\n#4 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(135): Magento\\Framework\\App\\Cache\\FlushCacheByTags->aroundSave(Object(Magento\\Customer\\Model\\ResourceModel\\Customer\\Interceptor), Object(Closure), Object(Magento\\Customer\\Model\\Customer\\Interceptor))\n#5 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Customer\\Model\\ResourceModel\\Customer\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Customer\\Model\\Customer\\Interceptor))\n#6 /var/www/html/magento2/generated/code/Magento/Customer/Model/ResourceModel/Customer/Interceptor.php(117): Magento\\Customer\\Model\\ResourceModel\\Customer\\Interceptor->___callPlugins('save', Array, NULL)\n#7 /var/www/html/magento2/vendor/magento/framework/Model/AbstractModel.php(647): Magento\\Customer\\Model\\ResourceModel\\Customer\\Interceptor->save(Object(Magento\\Customer\\Model\\Customer\\Interceptor))\n#8 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Framework\\Model\\AbstractModel->save()\n#9 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Customer\\Model\\Customer\\Interceptor->___callParent('save', Array)\n#10 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Customer\\Model\\Customer\\Interceptor->Magento\\Framework\\Interception\\{closure}()\n#11 /var/www/html/magento2/generated/code/Magento/Customer/Model/Customer/Interceptor.php(1118): Magento\\Customer\\Model\\Customer\\Interceptor->___callPlugins('save', Array, Array)\n#12 /var/www/html/magento2/vendor/magento/module-customer/Model/ResourceModel/CustomerRepository.php(206): Magento\\Customer\\Model\\Customer\\Interceptor->save()\n#13 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Customer\\Model\\ResourceModel\\CustomerRepository->save(Object(Magento\\Customer\\Model\\Data\\Customer), NULL)\n#14 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Customer\\Model\\ResourceModel\\CustomerRepository\\Interceptor->___callParent('save', Array)\n#15 /var/www/html/magento2/vendor/magento/module-customer/Model/Plugin/CustomerRepository/TransactionWrapper.php(44): Magento\\Customer\\Model\\ResourceModel\\CustomerRepository\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Customer\\Model\\Data\\Customer), NULL)\n#16 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(135): Magento\\Customer\\Model\\Plugin\\CustomerRepository\\TransactionWrapper->aroundSave(Object(Magento\\Customer\\Model\\ResourceModel\\CustomerRepository\\Interceptor), Object(Closure), Object(Magento\\Customer\\Model\\Data\\Customer), NULL)\n#17 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Customer\\Model\\ResourceModel\\CustomerRepository\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Customer\\Model\\Data\\Customer), NULL)\n#18 /var/www/html/magento2/generated/code/Magento/Customer/Model/ResourceModel/CustomerRepository/Interceptor.php(26): Magento\\Customer\\Model\\ResourceModel\\CustomerRepository\\Interceptor->___callPlugins('save', Array, Array)\n#19 [internal function]: Magento\\Customer\\Model\\ResourceModel\\CustomerRepository\\Interceptor->save(Object(Magento\\Customer\\Model\\Data\\Customer), NULL)\n#20 /var/www/html/magento2/vendor/magento/module-webapi/Controller/Rest.php(330): call_user_func_array(Array, Array)\n#21 /var/www/html/magento2/vendor/magento/module-webapi/Controller/Rest.php(239): Magento\\Webapi\\Controller\\Rest->processApiRequest()\n#22 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#23 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callParent('dispatch', Array)\n#24 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#25 /var/www/html/magento2/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(39): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n#26 /var/www/html/magento2/vendor/magento/framework/App/Http.php(135): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#27 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Framework\\App\\Http->launch()\n#28 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Framework\\App\\Http\\Interceptor->___callParent('launch', Array)\n#29 /var/www/html/magento2/app/code/MSP/APIEnhancer/Plugin/AppInterfacePlugin.php(75): Magento\\Framework\\App\\Http\\Interceptor->Magento\\Framework\\Interception\\{closure}()\n#30 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(135): MSP\\APIEnhancer\\Plugin\\AppInterfacePlugin->aroundLaunch(Object(Magento\\Framework\\App\\Http\\Interceptor), Object(Closure))\n#31 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Framework\\App\\Http\\Interceptor->Magento\\Framework\\Interception\\{closure}()\n#32 /var/www/html/magento2/generated/code/Magento/Framework/App/Http/Interceptor.php(26): Magento\\Framework\\App\\Http\\Interceptor->___callPlugins('launch', Array, NULL)\n#33 /var/www/html/magento2/vendor/magento/framework/App/Bootstrap.php(256): Magento\\Framework\\App\\Http\\Interceptor->launch()\n#34 /var/www/html/magento2/pub/index.php(37): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#35 {main}"


{
    "id": 7,
    "group_id": 1,
    "default_shipping": "17",
    "created_at": "2018-03-09 10:20:28",
    "updated_at": "2018-04-05 08:52:49",
    "created_in": "English",
    "email": "[email protected]",
    "firstname": "Nagaraju",
    "lastname": "Kasa",
    "store_id": 1,
    "website_id": 1,
    "addresses": [
        {
            "id": 17,
            "customer_id": 7,
            "region": {
                "region_code": "Tamilanadu",
                "region": "Tamilanadu",
                "region_id": 0
            },
            "region_id": 0,
            "country_id": "IN",
            "street": [
                "Chennai",
                "Nungambakam"
            ],
            "company": "TEst",
            "telephone": "7894561230",
            "fax": "123456",
            "postcode": "500068",
            "city": "Chennai",
            "firstname": "Nagaraju",
            "lastname": "KASA",
            "default_shipping": true,
            "custom_attributes": [
                {
                    "attribute_code": "city_id",
                    "value": "2",
                    "label": null
                }
            ]
        }
    ],
    "disable_auto_group_change": 0
}
10
  • are you call rest/V1/integration/customer/token api?
    – mohan
    Apr 5, 2018 at 12:06
  • yes @mohan i was generated token but while using put method getting the above error can u please provide me the raw data how i should pass in postman? Apr 5, 2018 at 12:11
  • customer token generation post method you should pass correct username and password,
    – mohan
    Apr 5, 2018 at 12:16
  • Can you please provide me the step by step\ Apr 5, 2018 at 12:18
  • 1
    prnt.sc/j18aa2 prnt.sc/j18alt Apr 5, 2018 at 12:26

2 Answers 2

2

your json parameter is wrong

{
    "id": 2,
    "group_id": 1,
    "default_billing": "2",
    "default_shipping": "2",
    "created_at": "2018-03-30 07:53:13",
    "updated_at": "2018-04-05 08:44:53",
    "created_in": "Default Store View",
    "email": "[email protected]",
    "firstname": "test",
    "lastname": "test",
    "store_id": 1,
    "website_id": 1,
    "addresses": [
        {
            "id": 2,
            "customer_id": 2,
            "region": {
                "region_code": "test",
                "region": "test",
                "region_id": 0
            },
            "region_id": 0,
            "country_id": "IN",
            "street": [
                "test"
            ],
            "telephone": "123123123",
            "postcode": "123123",
            "city": "test",
            "firstname": "test",
            "lastname": "test",
            "default_shipping": true,
            "default_billing": true
        }
    ]
}

user this json parameter

{
"customer":{
    "id": 2,
    "group_id": 1,
    "default_billing": "2",
    "default_shipping": "2",
    "created_at": "2018-03-30 07:53:13",
    "updated_at": "2018-04-05 08:44:53",
    "created_in": "Default Store View",
    "email": "[email protected]",
    "firstname": "test",
    "lastname": "test",
    "store_id": 1,
    "website_id": 1,
    "addresses": [
        {
            "id": 2,
            "customer_id": 2,
            "region": {
                "region_code": "test",
                "region": "test",
                "region_id": 0
            },
            "region_id": 0,
            "country_id": "IN",
            "street": [
                "test"
            ],
            "telephone": "123123123",
            "postcode": "123123",
            "city": "test",
            "firstname": "test",
            "lastname": "test",
            "default_shipping": true,
            "default_billing": true
        }
    ]
}
}

it working me

1
  • still same issue, I am getting "A customer with the same email address already exists" error Sep 29, 2020 at 11:22
-1

I think you need to refer following Magento Official Doc.

http://devdocs.magento.com/swagger/

http://devdocs.magento.com/guides/v2.2/rest/list.html

Hope It'll helps you.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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