5

There are API's available to fetch and delete address of a customer but not create a new one.

GET    /V1/customers/addresses/:addressId
GET    /V1/customers/me/billingAddress
GET    /V1/customers/:customerId/billingAddress
GET    /V1/customers/me/shippingAddress
GET    /V1/customers/:customerId/shippingAddress
DELETE /V1/addresses/:addressId

POST Api's are not available publicly?

6

I was having a similar problem and was digging into the AccountManagement class to find the proper payload. I noticed that the createAccount function checks if a customer ID exists and loads the stored data.

By performing a POST /V1/customers/:id, I was able to add another address with the following payload:

{ "customer":
    {
       "email":"testing2@testing.com",
       "firstname":"test",
       "lastname":"test",
       "websiteId": 0,
       "addresses": [
            {
                "id": 9,
                "firstname": "test",
                "lastname": "test",
                "company": "test technology",
                "street": [
                "Test Street 9",
                "Tiny House 9"
                ],
                "city": "City Nine",
                "region_id": 12,
                "region": "California",
                "postcode": "91790",
                "country_id": "US",
                "telephone": "1234567890"
            },
            {
                "firstname": "test",
                "lastname": "test",
                "company": "test technology",
                "street": [
                "Test Street 10",
                "Tiny House 10"
                ],
                "city": "City Ten",
                "region_id": 12,
                "region": "California",
                "postcode": "91790",
                "country_id": "US",
                "telephone": "1234567890"
            }
        ]
    }

By post method how did you do this actually when i am trying it is showing me error of missing route did you write webapi.xml code for this route.

  • In Magento 2.3, I tried PUT and it works like a charm! – Rizwan Dhuka Mar 7 at 14:13
5

It should be possible to add/update customer addresses using customer repository API:

PUT /V1/customers/:id (for admin)
PUT /V1/customers/me (for customer)
0

I'm using Magento 2.2, PUT and POST both do not work for adding a new address to an existing account. I get the following error:

"A customer with the same email already exists in an associated website"

Is adding an address to an existing Magento customer only supported in version 2.3 and later?

  • UPDATE: I was able to get the endpoint "PUT /V1/customers/:id" to work but an additional field was needed in the "customer" object. After adding an "id" field (Magento customer ID), I am able to add addresses to an already existing customer account. – y2alex007 May 2 at 22:25

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.