GET Requests to manipulate large collection results - Intergraph Smart Electrical - 2.1 - Help - Intergraph

Intergraph Smart Electrical Smart API Help

Language
English (United States)
Product
Intergraph Smart Electrical
Search by Category
Help
Smart Electrical Web Version
2.1

As you already discovered in the response to the request 03.01 Motors, the number of items that is retrieved in the payload is limited to 24. The pagination uses $top and $skip query options to select the next set of data. We recommend including the $orderby method on properties with distinct values as part of the request, so that pagination is consistent. In addition, we recommend including $count=true so that the next link is provided by the API only where there are additional items to go to.

The system queries add options to the request that help with keeping count of the number of items displayed in the result.

Method

Description

$orderby

The $orderby System query option specifies the order in which items are returned from the service.

$top

The $top System query option specifies a non-negative integer n that limits the number of items returned from a collection.

$skip

The $skip system query option specifies a non-negative integer n that excludes the first n items of the queried collection from the result

Pagination default

This request fetches the Items in ascending order, using the $orderby method to sort the items by Item Tag.

  1. Duplicate the request 03.04 Motors + order by Item Tag Asc + selected properties.

  2. Add the $count=true method to the request.

    https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/Motors/Com.Ingr.SEL.V2.WEBAPISITE001.PLANT001.Motor/?$count=true&$orderby= ItemTag&$select=Id,ItemTag,MotorRatedPower,RatedVoltage,aabbcc_code

    The bottom of the response displays a link to the next items, skipping the first 24 items:

  3. Copy the link and paste it in the GET address bar to retrieve the next set of 24 items.

Pagination top items

This request uses '$top' to include only the top number of items in the result. In this case, the request will display only the top three items in the payload (motors ordered by Item Tag).

  1. Select the request 05.01 Pagination top items and click Send.

  2. At the end of the previous request, add &$top=3 and click Send.

    https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/Motors/Com.Ingr.SEL.V2.WEBAPISITE001.PLANT001.Motor/?$count=true&$orderby= ItemTag&$select=Id,ItemTag,MotorRatedPower,RatedVoltage,aabbcc_code&$top=3

Pagination skip items

This request uses '$skip' to exclude the first n items in the result. In this case, the request will skip the first two items and display the next three items in the payload.

  1. Select the request 05.02 Pagination top / skip items and click Send.

    https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/Motors/Com.Ingr.SEL.V2.WEBAPISITE001.PLANT001.Motor/?$count=true&$orderby= ItemTag&$select=Id,ItemTag,MotorRatedPower,RatedVoltage,aabbcc_code&$top=3&$skip=2

  2. Select the request 05.01 Top items again and click Send.

  3. Compare the results of both requests and notice that the first record of the current request is the same as the third record of the previous request.

Pagination top items related to a specific item

This request expands the top two plant items on side 1 of a motor with Id=95A884DDC4714DF0FF30A6ABA5F869F2. You will need to choose a motor Id appropriate for your data set.

  • Select the request 05.03 Top 2 plant items for specific motor and click Send.

    https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/Motors('95A884DDC4714DF0FF30A6ABA5F869F2')/PlantItem1s/Com.Ingr.SEL.V2.WEBAPISITE001.PLANT001.PlantItem/?$count=true&$orderby= ItemTag&$select=Id,ItemTag,aabbcc_code&$top=2