4
delete /V1/addresses/{addressId}

This is the Delete Address REST API in Magento 2.

It works with admin tokens, but not with customer tokens.

I think it should be working with custom tokens as customers should have the right to delete their own addresses stored.

This API has access permission for Resource: Magento_Customer::manage

This resource permission should be working with customer token, isn't it?

Does anybody have the same issue?

1 Answer 1

1

Customer token CANNOT access customerAddressRepositoryV1 so your API doesn't work on customer token. This is how swagger looks after inserting a customer token: enter image description here

If customer wants to modify/delete customer address, we can use PUT /V1/customer/me. Although it doesn't list on swagger(Confirmed: it's a bug), it tested and successful on my 2.1.7 EE + POSTMAN. Here is a sample JSON for using PUT /V1/customer/me:

{
  "customer": {
    "email": "your_email",
    "firstname": "your_firstname",
    "lastname": "your_lastname",
    "website_id": 1,
    "addresses": [

    ],
    ...
   }
}

Of course, you have to add token on header.

3
  • 1
    Thanks for your efforts.. I found that if there is a resource Magento_Customer::manage applied on webapi.xml , it indicates that we need to use admin token. And if Magento_Customer::customer resource is applied in any API, we can use customer token. Commented Aug 20, 2017 at 7:18
  • So i needed to use admin token. But I think my question can be considered as an enhancement for magento team. as customer should have rights to delete his own address with customer token. Thanks again... Commented Aug 20, 2017 at 7:20
  • Yes I think it should be an enhancement on it. BTW if my workaround works please accept my answer :)
    – PY Yick
    Commented Aug 20, 2017 at 10:49

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.