我已在 Business Central 中创建了此 API 页面:
page 60012 CustomerPL
{
PageType = API;
EntitySetName = 'customerPLs';
EntityName = 'customerPL';
APIPublisher = 'MyCompany';
APIGroup = 'MyCompany';
SourceTable = "Customer";
InsertAllowed = false;
ModifyAllowed = false;
DeleteAllowed = false;
layout
{
area(content)
{
repeater(Group)
{
field("Cliente"; Rec."No.")
{
ApplicationArea = All;
}
part(partCustomerBanksPL; 60013)
{
ApplicationArea = All;
EntitySetName = 'partCustomerBanksPLs';
EntityName = 'partCustomerBanksPL';
SubPageLink = "Customer No." = field("No.");
}
}
}
}
}
我的想法是在本指南
之后的嵌套 json 中提供包含银行、地址等的客户 Web 服务这是列表部分:
page 60013 partCustomerBanksPL
{
ApplicationArea = All;
Caption = 'Bancos clientes PL';
PageType = ListPart;
SourceTable = "Customer Bank Account";
layout
{
area(content)
{
repeater(General)
{
field("Code"; Rec."Code")
{
}
field(Name; Rec.Name)
{
}
field(IBAN; Rec.IBAN)
{
}
field("SWIFT Code"; Rec."SWIFT Code")
{
}
}
}
}
}
运行 GET 请求:
https://api.businesscentral.dynamics.com/v2.0/{{tenant_id}}/Sandbox_PL/ODataV4/Company('MyCompany')/customerPL?$expand=partCustomerBanksPL
我收到此错误:
{
"error": {
"code": "BadRequest",
"message": "Could not find a property named 'partCustomerBanksPL' on type 'NAV.customerPL'. CorrelationId: 34fca7a0-ae62-4218-90f1-09ad53e0cfc0."
}
}
那么...如何像我尝试的那样在 Business Central 中使用页面部件创建嵌套 Web 服务?
编辑:更新代码以匹配名称和驼峰命名法
添加 APIVersion 属性
page 60012 CustomerPL
{
...
APIPublisher = 'MyCompany';
APIGroup = 'MyCompany';
APIVersion = 'v1.0';
...
并使用以下 HTTP 请求:https://api.businesscentral.dynamics.com/v2.0/