【问题标题】:Microsoft Dynamics Business Central REST API does not return the full list of fieldsMicrosoft Dynamics Business Central REST API 不返回完整的字段列表
【发布时间】:2022-07-11 23:13:14
【问题描述】:

我正在尝试从 Business Central Customer 实体中获取所有字段,但 API 未返回页面上表示的完整属性列表

所以我正在运行以下请求

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'

除了标准之外,还期望获得这些属性,但作为请求的结果,我得到了以下数据:

{
    "@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"
                }
            ]
        }
    ]
}

【问题讨论】:

    标签: .net rest microsoft-dynamics dynamics-business-central


    【解决方案1】:

    标准 API 不会返回大部分 OOTB 字段,因此您必须编写自己的 API 来执行此操作。

    对于客户,这很简单,因为客户 API 的源表确实包含所有这些字段。

    本博客介绍了向客户 API 添加新字段:

    https://www.kauffmann.nl/2021/03/12/extending-standard-apis-1/

    添加现有字段是一样的,只是你只需要修改API,不需要表格扩展。

    对于其他实体,例如销售订单/销售发票,它更加复杂,因为现有 API 的表源不包含所有 OOTB 字段,因此您将不得不跳过更多的步骤来复制这些从实际源表到缓冲区/聚合表的字段,以便它们可以在 API 上显示。该博客系列的第二篇文章介绍了这种情况。

    很难相信所有这些都是通过 API 读取开箱即用字段所必需的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-14
      • 1970-01-01
      • 1970-01-01
      • 2023-02-19
      • 2021-09-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多