• Not Answered

I am unable to create Users, addresses under each user and unable to pull those addresses from Sitecore e-commerce using the following methods in the browser console.

I am unable to create Users, addresses under each user and unable to pull those addresses from Sitecore e-commerce using the following methods in the browser console.

function getQueryStringParamValue(param) {
    return getUrlParameter(location.href, param)
}

```
To **create a new user** open console and run the following javascript:
```javascript
AjaxService.PostExt('/api/cxa/Account/Registration', {
    UserName: 'new.user@mail.com',
    Password: "Admin123",
    ConfirmPassword: "Admin123"
}, () => {})
```
(change user name and password if needed).

To **login user**, run the following code:
```javascript
AjaxService.PostExt('/api/cxa/Account/Login', {
    UserName: 'new.user@mail.com',
    Password: "Admin123"
}, () => {})
```

To **create new address for logged in user** run the following code (or you could add/edit/delete addresses in Business Tools):
```javascript
AjaxService.PostExt('/api/cxa/AccountAddress/AddressEditorModify', {
    Name: "User Address 2",
    Address1: "3571  Stroop Hill Road",
    City: "Atlanta",
    State: "GA",
    Country: "US",
    ZipPostalCode: "30305"
}, () => {})
```

To **get all current user addresses**:
```javascript
AjaxService.PostExt('/api/cxa/AccountAddress/GetAddressList', {
    maxRecordsToShow: 100
}, () => {})
```

Sample response for **all addresses**:
```json
{
    "ModelProvider": {},
    "Addresses": [{
        "ExternalId": "2d74039d94fb4bf597b34ee5cfe8adb2",
        "Name": "User Address",
        "FullAddress": "3571  Stroop Hill Road, Atlanta, 30305",
        "Address1": "3571  Stroop Hill Road",
        "Address2": null,
        "City": "Atlanta",
        "Country": "US",
        "IsPrimary": false,
        "State": "GA",
        "Errors": [],
        "Info": [],
        "Warnings": [],
        "HasErrors": false,
        "HasInfo": false,
        "HasWarnings": false,
        "Success": true,
        "Url": null,
        "ContentEncoding": null,
        "ContentType": null,
        "Data": null,
        "JsonRequestBehavior": 1,
        "MaxJsonLength": null,
        "RecursionLimit": null
    }, {
        "ExternalId": "dd3eed39606c4f6093be0f7d9e0d188b",
        "Name": "User Address 2",
        "FullAddress": "3571  Stroop Hill Road, Atlanta, 30305",
        "Address1": "3571  Stroop Hill Road",
        "Address2": null,
        "City": "Atlanta",
        "Country": "US",
        "IsPrimary": false,
        "State": "GA",
        "Errors": [],
        "Info": [],
        "Warnings": [],
        "HasErrors": false,
        "HasInfo": false,
        "HasWarnings": false,
        "Success": true,
        "Url": null,
        "ContentEncoding": null,
        "ContentType": null,
        "Data": null,
        "JsonRequestBehavior": 1,
        "MaxJsonLength": null,
        "RecursionLimit": null
    }],
    "Errors": [],
    "Info": [],
    "Warnings": [],
    "HasErrors": false,
    "HasInfo": false,
    "HasWarnings": false,
    "Success": true,
    "Url": null,
    "ContentEncoding": null,
    "ContentType": null,
    "Data": null,
    "JsonRequestBehavior": 1,
    "MaxJsonLength": null,
    "RecursionLimit": null
}
```

For more **Address Actions** please review code from `Sitecore.Commerce.XA.Feature.Account.Controllers.AccountAddressController`.