OData4 REST v2 expand sub tables

I have been testing the REST api v2 and ran into some issues and just want to share it with everyone.
When calling SalesOrderSvc\SalesOrder GET command, we use expand to pull in the sub tables.
{{Host}}/{{Environment}}/api/v1/Erp.BO.SalesOrderSvc/SalesOrders?$expand=OrderDtls,OHOrderMscs, OrderDtls/OrderRels, OrderDtls/OrderMscs&$filter=OrderNum eq 800500

In Rest v2 this call does not work and you get a path error. This is the new format.

{{Host}}/{{Environment}}/{{path}}/{{Company}}/Erp.BO.SalesOrderSvc/SalesOrders?$expand=OrderDtls,OHOrderMscs,OrderDtls($expand=OrderRels), OrderDtls($expand=OrderMscs)&$filter=OrderNum eq 800500

Thanks
David

1 Like

Hey David,

This is not an issue in REST API v2. Your query is just not a valid OData v.4 query. It is the reason why you got a path error. OData parser cannot process it.
Valid form is

{{Host}}/{{Environment}}/{{path}}/{{Company}}/Erp.BO.SalesOrderSvc/SalesOrders?$expand=OrderDtls($expand=OrderRels,OrderMscs),OHOrderMscs&$filter=OrderNum eq 800500

EntitySet (table) can be used only once in the scope of $expand statement. All its children should be specified as one list (if any).

5 Likes

It also looks a lot cleaner statement. Thanks for the info.