How to expand multiple properties on OData

According to OData ABNF, expand syntax should be:

expand = '$expand' EQ expandItem *( COMMA expandItem )

Which amounts to:

$expand=expandItem1,expandItem2,expandItem3,...

So please try:

http://services.odata.org/northwind/northwind.svc/Categories?$expand=Products/Category,Products/Supplier


For more information, see:

http://www.odata.org/documentation/odata-version-2-0/uri-conventions/#ExpandSystemQueryOption


For our SAP consultants out there: We're able to use multi-levels in oData as well. You need to pass it this way:

<host>/API_BUSINESS_PARTNER/Identification?$expand=to_Parent,to_Parent/to_Role

The example above provides you the ability to fetch the expands of another expand. In this case to_parent -> to_Role. "to_Role" is only available at the parent level.


You can also try this syntax for expanding multiple levels:

$expand=Products($expand=Category),...

This works well with MS OData implementation in WebAPI.

Tags:

Odata