web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

$Expand does not work on Custom API

(1) ShareShare
ReportReport
Posted on by 12
Hi Everyone,
 
I have a Power Automate HTTP that retrieve Customer Info with standard BC APIv2 
 
It's all working fine and I received the output with various Navigation Property (currency, paymentTerm etc) expanded.
 
However, when I have a custom API for customers
 
It does not seem to recognize the navigation property and I have the error "Action 'GetCustomer' failed: Could not find a property named 'paymentTerm' on type 'Microsoft.NAV.customer' "

Changing back to standard API and it works again. The same happened for currency, shipmentMethod and all other navigation property.

Would appreciate if someone could provide a pointer on how to make the $expand work on custom api ? I downloaded the Customers API page from ALAppExtensions/Apps/W1/APIV2/app/src/pages/APIV2Customers.Page.al at main · microsoft/ALAppExtensions · GitHub and only added a field CreditLevel.
 
Thank you so much in advanced.
 
-Josh
 
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,765 Super User 2025 Season 2 on at
    It looks like a problem with the custom API code. First, completely copy the standard API page and try to see if there is any problem. Then make some changes such as adding fields. Try not to modify its logic.
     
    Hope this can give you some hints.
    Thanks.
    ZHU
  • CU22100512-0 Profile Picture
    12 on at
    Hi Zhu,
     
    Thanks for replying. Actually I copy and paste exact code from ALAppExtensions/Apps/W1/APIV2/app/src/pages/APIV2Customers.Page.al at main · microsoft/ALAppExtensions · GitHub and only added a field CreditLevel and nothing else.
     
    Correction to my original post :
    currency, paymentTerm, shipmentMethod, paymentMethod did not work (could not find property name), But customerFinancialDetaildefaultDimensions, agedAccountsReceivable, and contactsInformation did expand.
     
    I looked at the Github code and the Part sections contained only customerFinancialDetail, defaultDimensions, agedAccountsReceivable, and contactsInformation. $metadata also returned these as Navigation Property.
     
    So I added below Part for currency and paymentTerm. Both can be expanded now. I just wonder why the Github API code did not contain these 2 ?
     
      part(currency; "APIV2 - Currencies")
                    {
                        Caption = 'Currencies';
                        Multiplicity = ZeroOrOne;
                        EntityName = 'currency';
                        EntitySetName = 'currencies';
                        SubPageLink = SystemId = field("Currency Id");
                    }
                    part(paymentTerm; "APIV2 - Payment Terms")
                    {
                        Caption = 'Payment Terms';
                        Multiplicity = ZeroOrOne;
                        EntityName = 'paymentTerm';
                        EntitySetName = 'paymentTerms';
                        SubPageLink = SystemId = field("Payment Terms Id");
                    }
     
    Regards,
    Josh
  • CU22100512-0 Profile Picture
    12 on at
    Hi All,
     
    After added Part and the expansion works now. Another follow up question is $expand=currency,paymentTerm etc, where are these keywords (currency, paymentTerm etc) being defined ? As if I change $expand=paymentTerms (with s) is won't recognize. 

    Is it follow the name of the part ? like below ? but if I change to part(currencies; "APIV2 - Currencies") it is still working. SO I am a bit puzzle where the expansion keyword being defined. with s or without s
     part(currency; "APIV2 - Currencies")
     
    Thank you in advance.
     
    Regards,
    Josh
  • Khushbu Rajvi. Profile Picture
    20,975 Super User 2025 Season 2 on at

    Yes, the $expand keyword in Business Central APIs follows the EntityName defined in the part declaration, not the actual variable name used in the part block. In your example:

    The $expand=currency works because it matches the EntityName = 'currency'. The name you use for the part (in this case, currency or currencies) is a local variable name for the page, but the API uses the EntityName property for $expand.

    If you were to change the EntityName to something else, like 'currencies', then you would need to use $expand=currencies in the API call. So the keyword for $expand is always derived from the EntityName, regardless of the part name you use.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,856

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 765 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 581 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans