I've created this API page in Business Central:
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.");
}
}
}
}
}
My idea is to have a Customer web service with banks, addresses, etc. in a nested json following this guide
This is the ListPart:
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")
{
}
}
}
}
}
Running the GET request:
https://api.businesscentral.dynamics.com/v2.0/{{tenant_id}}/Sandbox_PL/ODataV4/Company('MyCompany')/customerPL?$expand=partCustomerBanksPL
I'm getting this error:
{
"error": {
"code": "BadRequest",
"message": "Could not find a property named 'partCustomerBanksPL' on type 'NAV.customerPL'. CorrelationId: 34fca7a0-ae62-4218-90f1-09ad53e0cfc0."
}
}
So... How can I create a nested web service in Business Central with Page Parts like I'm trying?
EDIT: code updated to match names and camelCase
Add the APIVersion property
page 60012 CustomerPL
{
...
APIPublisher = 'MyCompany';
APIGroup = 'MyCompany';
APIVersion = 'v1.0';
...
and use the following HTTP request: https://api.businesscentral.dynamics.com/v2.0/>tenant_id</Sandbox_PL/api/MyCompany/MyCompany/v1.0/companies(>companyId<)/customerPLs?$expand=partCustomerBanksPLs
EDIT: Take a look at the official MS documentation on Creating API pages: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-develop-custom-api#to-create-api-pages-to-display-car-brand-and-car-model