Customers and addresses

    Get a customer's address list

    This API endpoint is used to list a customer's addresses

    Request

    • Method: GET
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/customers/[customer_ID]/addresses
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    The list of addresses in JSON format.

    • addressId - the id of the address (integer)
    • siteId - the id of the site (integer)
    • customerId - the id of the CRM record (integer)
    • addressTypeId -the ID of the address type (integer)
      • 1 - Home address
      • 2 - Work address
      • 3 - PO box
      • 8 - Billing address
    • default - whether this is the record's default address (boolean)
    • address1 (string)
    • address2 (string)
    • zipCode (string)
    • suburb (string)
    • countryCode (string)
    • state (string)

    The response is paginated, you can return only a few of the customer's fields. Take a look at the API V3: sorting and filtering for additional switches you can use.

    You can output additional fields to those listed above as default, see the API v3 Discovery APP for additional details.

    Accepts and returns JSON as Content-Type.


    Request:

    GET /webresources/api/v3/sites/current/customers/7051740/addresses HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    {
      "items": [
        {
          "id": 2466330,
          "siteId": 1576341,
          "addressType": 1,
          "objectId": 9593213,
          "objectType": 1001,
          "default": true,
          "address1": "",
          "address2": null,
          "zipCode": "",
          "suburb": "",
          "countryCode": "RO",
          "state": ""
        },
        {
          "id": 2489251,
          "siteId": 1576341,
          "addressType": 2,
          "objectId": 9593213,
          "objectType": 1001,
          "default": false,
          "address1": "",
          "address2": null,
          "zipCode": "",
          "suburb": "",
          "countryCode": "RO",
          "state": "WS"
        }
      ],
      "totalItemsCount": 2,
      "skip": 0,
      "limit": 10
    }

    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/customers/7051740/addresses",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })