Search code examples
odatamicrosoft-dynamicsdynamics-business-central

Business Central API | Find $Expand property name


Let's say I wanted to retrieve the sales headers along with their lines, I would use the following URL: https://api.businesscentral.dynamics.com/v2.0/{GUID}/Sandbox/ODataV4/Company('{CompanyName}')/SalesInvoice?$expand=SalesInvoiceSalesLines

And if I wanted to retrieve the Purchase Invoice, I would use this one:

https://api.businesscentral.dynamics.com/v2.0/{GUID}/Sandbox/ODataV4/Company('{CompanyName}')/PurchaseInvoice?$expand=PurchaseInvoicePurchLines

So, for the sales, the expand property has the value SalesInvoiceSalesLines while for the purchases, the value is PurchaseInvoicePurchLines.

Is there some logic or a documentation that can help me find what the expand property's value needs to be if I want to expand, say, the SalesCreditMemo lines ?


Solution

  • You should be able to deduct that from the metadata of the endpoint in question e.g.:

    https://api.businesscentral.dynamics.com/v2.0/{GUID}/Sandbox/ODataV4/$metadata#Company('{CompanyName}')/SalesCreditMemo

    Then search for "Line" in the the returned XML document.