MarkJoel60
MarkJoel60

Reputation: 557

Why Does Calling Expand and Select on a PUT result in LESS information being returned - Acumatica REST API

In the example for Acumatica: "Lesson 2.1: Updating a Customer Account" the sample code will update the customer's Contact info, based on retrieving it by the email address. It expands the MainContact and selects CustomerID and CustomerClass:

https://localhost/MyStoreInstance/entity/Default/18.200.001/Customer?$filter=MainContact/Email eq '[email protected]'&$expand=MainContact&$select=CustomerID,CustomerClass

Postman Screenshot 1 The values that are returned include CustomerID, CustomerClass PLUS a fully loaded BillingContact record, comprising 2150 Bytes of data like this:

{
    "id": "0b88d208-297a-4b81-a20c-39d27bace10a",
    "rowNumber": 1,
    "note": "",
    "BillingContact": {
        "id": "e1133b8a-fca9-4885-8e4c-09a85808f025",
        "rowNumber": 1,
        "note": null,
        "Activities": [],
        "Address": {
            "id": "4f1719aa-6eb0-4551-a143-ad2139e135aa",
            "rowNumber": 1,
            "note": null,
            "AddressLine1": {
                "value": "1000 Pennsylvania Ave"
            },
            "AddressLine2": {},
            "City": {
                "value": "San Francisco"
            },
            "Country": {
                "value": "US"
            },
            "PostalCode": {
                "value": "94107-3479"
            },
            "State": {
                "value": "CA"
            },
            "custom": {},
            "files": []
        },
        "Attention": {
            "value": "Mister. Jack Green"
        },
        "Attributes": [],
        "Campaigns": [],
        "Cases": [],
        "ContactID": {
            "value": 12417
        },
        "DisplayName": {
            "value": "Jevy Computers"
        },
        "Duplicates": [],
        "Email": {
            "value": "[email protected]"
        },
        "Fax": {},
        "FirstName": {},
        "JobTitle": {
            "value": ""
        },
        "LastName": {},
        "MarketingLists": [],
        "MiddleName": {},
        "Notifications": [],
        "Opportunities": [],
        "Phone1": {
            "value": "+1 (777) 380-0089"
        },
        "Phone1Type": {
            "value": "Business 1"
        },
        "Phone2": {},
        "Phone2Type": {
            "value": "Business 2"
        },
        "Relations": [],
        "Title": {},
        "UserInfo": null,
        "WebSite": {},
        "custom": {},
        "files": []
    },
    "BillingContactSameAsMain": {
        "value": false
    },
    "CustomerClass": {
        "value": "INTL"
    },
    "CustomerID": {
        "value": "C000000003"
    },
    "custom": {},
    "files": []
}

However, when I explicitly ask for BillingContact to be Expanded, I get LESS information than I get when I omit it from the EXPAND command altogether. (I get 1235 bytes in return.)

Postman Screenshot 2:

{
    "id": "0b88d208-297a-4b81-a20c-39d27bace10a",
    "rowNumber": 1,
    "note": "",
    "BillingContact": {
        "id": "e1133b8a-fca9-4885-8e4c-09a85808f025",
        "rowNumber": 1,
        "note": null,
        "Attention": {
            "value": "Mr. Jack Green"
        },
        "ContactID": {
            "value": 12417
        },
        "DisplayName": {
            "value": "Jevy Computers"
        },
        "Email": {
            "value": "[email protected]"
        },
        "Fax": {},
        "FirstName": {},
        "JobTitle": {
            "value": ""
        },
        "LastName": {},
        "MiddleName": {},
        "Phone1": {
            "value": "+1 (777) 380-0089"
        },
        "Phone1Type": {
            "value": "Business 1"
        },
        "Phone2": {},
        "Phone2Type": {
            "value": "Business 2"
        },
        "Title": {},
        "WebSite": {},
        "custom": {},
        "files": []
    },
    "BillingContactSameAsMain": {
        "value": false
    },
    "CustomerClass": {
        "value": "INTL"
    },
    "CustomerID": {
        "value": "C000000003"
    },
    "custom": {},
    "files": []
}

Clearly I do not understand how the expand command is operating in a PUT. Can anyone explain it to me?

Why does including BillingContact in the expand command give me less BillingContact information?

Upvotes: 0

Views: 293

Answers (1)

Dmitrii Naumov
Dmitrii Naumov

Reputation: 1712

When you execute a Put request, Acumatica automatically add expands for the entities your are touching, including subentities, so you see Address under BillingContact. When you add expand on the billing contact, it overrides the default expands and you do not see Address any more. To get Address in the result, you add another expand : BillingContact/Address

Same applies to all other entities

Upvotes: 2

Related Questions