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:
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 ?
You should be able to deduct that from the metadata of the endpoint in question e.g.:
Then search for "Line" in the the returned XML document.