The following set of queries uses the $expand query option to expose the source entity as well as the target item. When using $expand, always provide the Id of the source item (do not use the $expand method without stating which item Id to expand).
GET request $expand - (Instrument -> Loop)
This request navigates from the Instrument (Id '4196') to its Loop, with a subset of three of the instrument properties: Id, InstrumentName, and PIDDrawing. The payload also includes all the properties of the loop.
-
Select the 06.01 $expand - (Instrument -> Loop) request and select Send.
{{baseUri}}api/si/{{versionNumber}}/Sites('{{SiteId}}')/PlantGroups('{{PlantGroupId}}')/Projects('0')/InstrumentProject('4196')?$select=Id,InstrumentName,PIDDrawing&$expand=InstrumentLoop
GET request $expand - (Loop -> Instrument) + expanded properties
This request expands the loop to display its instruments with a subset of both loop and instrument properties.
-
Select the 06.02 $expand - (Loop -> Instrument) + expanded properties request and select Send.
{{baseUri}}api/si/{{versionNumber}}/Sites('{{SiteId}}')/PlantGroups('{{PlantGroupId}}')/Projects('0')/LoopProject('4195')?$select=Id,LoopName,LoopService&$expand=InstrumentLoop($select=Id,InstrumentName,InstrumentType)
GET request $expand - (Loop -> Instrument) + expanded properties & count
This request is similar to the previous one, with the addition of the '$count' option, to reveal the number of Instruments associated with this Loop.
-
Select the 06.03 $expand - (Loop -> Instrument) + expanded properties & count request and select Send.
{{baseUri}}api/si/{{versionNumber}}/Sites('{{SiteId}}')/PlantGroups('{{PlantGroupId}}')/Projects('0')/LoopProject('4195')?$select=Id,LoopName,LoopService&$expand=InstrumentLoop($select=Id,InstrumentName,InstrumentType;$count=true)
GET request $expand - (Loop -> Instrument), + expanded properties, count, and sort order
This request is similar to the previous one, with the addition of the '$orderby' option, to reveal the number of Instruments connected to this Loop, and to display them in descending order.
-
Select the 06.04 $expand - (Loop -> Instrument) + expanded properties, count & orderby request and select Send.
{{baseUri}}api/si/{{versionNumber}}/Sites('{{SiteId}}')/PlantGroups('{{PlantGroupId}}')/Projects('0')/LoopProject('4195')?$select=Id,LoopName,LoopService&$expand=InstrumentLoop($select=Id,InstrumentName,InstrumentType;$count=true;$orderby=InstrumentName desc)
GET request $expand (Line > Instrument), plus expanded properties & filter
This request demonstrates the use of $filter query option for an expanded item.
-
Select the 06.05 $expand - (Line > Instrument) + expanded properties & filter request and select Send.
{{baseUri}}api/si/{{versionNumber}}/Sites('{{SiteId}}')/PlantGroups('{{PlantGroupId}}')/Projects('0')/LineProject('4139')?$select=Id,LineNumberName,PipeSize,LineSizeUnits&$expand=InstrumentLine1st($select=Id,InstrumentName,LoopName,PIDDrawing;$filter=LoopName eq '101-F -100')
GET request $expand Cable to End1Panel & End2Panel
This request expands a cable to the destination panels at both ends.
-
Select the 06.06 $expand Cable to CableEnd1Panel, CableEnd2Panel request and select Send.
{{baseUri}}api/si/{{versionNumber}}/Sites('{{SiteId}}')/PlantGroups('{{PlantGroupId}}')/Cables('4568')?$select=Id,CableName&$expand=CableEnd1Panel($select=Id,PanelName),CableEnd2Panel($select=Id,PanelName)
Additional capabilities using $expand requests
The following additional capabilities are available in SI Web API 2.3.14:
-
Support for multiple item $expand (without specifying the expanded item Id).
-
Support expansion of multiple navigation properties
-
Expansion is one level "deep" only.
-
Multiple $expand requests can take longer time to get the payload.
-
It is recommended to use query options.
GET request $expand Loop to Instruments
This request retrieves the loops expanded to their related instruments.
-
Select the 06.07 $expand - (Loop -> Instrument) + expanded properties+count+orderby request and select Send.
{{baseUri}}api/si/{{versionNumber}}/Sites('{{SiteId}}')/PlantGroups('{{PlantGroupId}}')/Projects('0')/LoopProject?$select=Id,LoopName,LoopService&$expand=InstrumentLoop($select=Id,InstrumentName,InstrumentType;$count=true;$orderby=InstrumentName desc)
Review the payload of this request.
GET request $expand Multi-Navigation properties
The request filters cables with “JB” in the name, expands the cable sets and cable wires.
-
Select the 06.08 $expand: Multi Navigation properties request and select Send.
{{baseUri}}api/si/{{versionNumber}}/Sites('{{SiteId}}')/PlantGroups('{{PlantGroupId}}')/Cables?$select=Id,CableName&$filter=(contains(CableName,'JB'))&$expand=CableSetCable($select=Id,CableSetName,CableSetSequence;$count=true;$orderby=CableSetSequence ),WireCable($select=Id,WireTagName,CableSetName,Polarity;$count=true;$orderby=Id,WireSequenceInSet)
Review the payload containing JB cables-sets and wires.