I'm trying to get all fields from the Business Central Customer entity, and API doesn't return the full list of properties that represented on the page
So I'm running the following request
https://api.businesscentral.dynamics.com/v2.0/DEV_ENV/api/v2.0/companies(3a6a4d9e-0000-0000-0000-d4bf220a4312)/customers?$expand=currency, paymentTerm, shipmentMethod, paymentMethod, customerFinancialDetail, defaultDimensions, agedAccountsReceivable, contactsInformation&$filter=number eq '1003058'
And expect to get also these properties in addition to the standard, but as the result of the request I'm getting the following data:
{
"@odata.context": "https://api.businesscentral.dynamics.com/v2.0/DEV_ENV/api/v2.0/$metadata#companies(3a6a4d9e-0000-0000-0000-d4bf220a4312)/customers",
"value": [
{
"@odata.etag": "W/\"qwert\"",
"id": "40ae2178-0000-0000-0000-00224827599f",
"number": "1003058",
"displayName": "Test Cust",
"type": "Company",
"addressLine1": "line 1",
"addressLine2": "",
"city": "Cali",
"state": "CA",
"country": "US",
"postalCode": "000000",
"phoneNumber": "12345678",
"email": "test@test.com",
"website": "",
"salespersonCode": "",
"balanceDue": 1819,
"creditLimit": 0,
"taxLiable": false,
"taxAreaId": "00000000-0000-0000-0000-000000000000",
"taxAreaDisplayName": "",
"taxRegistrationNumber": "",
"currencyId": "00000000-0000-0000-0000-000000000000",
"currencyCode": "USD",
"paymentTermsId": "a2ba2a82-0000-0000-0000-0022482c59bf",
"shipmentMethodId": "00000000-0000-0000-0000-000000000000",
"paymentMethodId": "00000000-0000-0000-0000-000000000000",
"blocked": "_x0020_",
"lastModifiedDateTime": "2022-03-29T20:16:25.853Z",
"currency": null,
"paymentTerm": {
"@odata.etag": "W/\"23556\"",
"id": "a2ba2a82-0000-0000-0000-0022482c59bf",
"code": "NET 30",
"displayName": "",
"dueDateCalculation": "30D",
"discountDateCalculation": "",
"discountPercent": 0,
"calculateDiscountOnCreditMemos": false,
"lastModifiedDateTime": "2022-04-30T04:35:25.47Z"
},
"shipmentMethod": null,
"paymentMethod": null,
"customerFinancialDetail": {
"@odata.etag": "W/\"tyuutu=\"",
"id": "40ae2178-0000-0000-0000-00224827599f",
"number": "1000000",
"balance": 1819,
"totalSalesExcludingTax": 2168,
"overdueAmount": 0
},
"defaultDimensions": [],
"agedAccountsReceivable": {
"@odata.etag": "W/\"qwer123\"",
"customerId": "40ae2178-0000-0000-0000-00224827599f",
"customerNumber": "100000",
"name": "cust name",
"currencyCode": "",
"balanceDue": 1819,
"currentAmount": 1819,
"period1Amount": 0,
"period2Amount": 0,
"period3Amount": 0,
"agedAsOfDate": "2022-05-18",
"periodLengthFilter": "30D"
},
"contactsInformation": [
{
"@odata.etag": "W/\"Jqwert\"",
"contactId": "71a7194a-0000-0000-0000-000d3a4e517b",
"contactNumber": "CT000000",
"contactName": "My",
"contactType": "Company",
"relatedId": "40ae2178-0000-0000-0000-00224827599f",
"relatedType": "Customer"
}
]
}
]
}
The standard APIs do not return most of the OOTB fields and so you will have to write your own API to do this.
With customers this is straightforward as the source table for the Customers API does include all these fields.
This blog covers adding a new field to the Customers API:
https://www.kauffmann.nl/2021/03/12/extending-standard-apis-1/
Adding an existing field is the same except you only need to modify the API, no need for a tableextension.
For other entities such as Sales Order / Sales Invoices it is more convoluted as the existing APIs have table sources which don't contain all the OOTB fields to begin with so you will have to jump through a few more hoops to copy these fields from the actual source tables to the buffer / aggregate tables so they can be surfaced on the API. The second post in that blog series covers this scenario.
Hard to believe all this is necessary to read out of the box fields via an API.