Creating the "Assets" Query


First, this section explains how to set up a simple query that returns assets and selected attributes. The second part explains the parameters and data in more detail.

Note: You will need the tenant name and GUID that Bentley assigned to your database, as well as Read access to the API.

To Create the “Assets” Query

1. In your workspace in Postman, select the collection you created previously (for example, “Bentley Reliability API”).

2. Right-click the collection name and click Add Request.

The Save Request dialog appears:

3. Name the request, for example, “Assets”. Click Save.

4. Select the new request in the collection so that you can set up parameters for the query.

5. In the GET line, enter the query:

https://reliability.bentley.com/odata/mnt.assets?$select=AssetNumber,Title&$expand=AssetType($select=TypeName)&$count=true&$skip=50$top=20

6. Set the request to inherit authorization from the collection. Select the Authorization tab. Select Inherit auth from parent.

7. Next, tell the request which tenant to access. Select the Headers tab.

8. In the Key field, enter the tenant name assigned by Bentley to your database: "X-Tenant". In the Value field, enter the GUID for the database.

9. Click Send.

The Body section displays the result of the request. In this case, assets and their properties are returned. The GET line includes the asset properties, for example, AssetNumber, Title, and AssetType.

10. Scroll down in the Body section to see the values returned.

More about the “Assets” Query

Let’s look at the “Assets” query in more depth to see how it works.

Here again is the request URL from the GET line:

https://reliability.bentley.com/odata/mnt.assets?$select=AssetNumber,Title&$expand=AssetType($select=TypeName)&$count=true&$skip=50$top=20

Query parameters are appended to the request URL, following “?”, and listed in key value pairs separated by “&”, using the following syntax: “?id=1&type=new”.

You can build your query using the GET line and with the help of the Params tab. Expand the Query Params section:

Here’s a breakdown of the query statement:

https://reliability.bentley.com/odata

Base URL for the request. Parameters must be URL encoded.

/mnt.assets

Endpoint path. The namespace “mnt” stands for the Maintenance Management system, and “assets” is the entity set of the class to be returned.

You must know the namespace (mnt) and entity set (assets) to query. To return a specific object, use its UUID (Universally Unique Identifier):

/{namespace}.{entity set}/{uuid}

$select=AssetNumber,Title

$select allows you to limit the data being returned. Otherwise, all fields for the object are returned. In this case, $select identifies the selected attributes of the asset object: number and title.

Here’s an example of the returned data:

Tip:       If you’re not sure what attributes you wish to get, try clearing the $select key and clicking Send. All of the asset properties are returned, and you can scroll through the Body section to locate the attributes you want.

$expand=AssetType($select=TypeName)

$expand specifies a relationship (or join in SQL) between classes, in this case, Asset and AssetType. The $select parameter that follows means that the asset type’s TypeName is returned. For example:

Embedded expands are supported, for example, “$expand=MostRecentReading($expand=Acknowledgement,AlarmType)” would include the acknowledgement and alarm type from the most recent reading.

The current expand depth is five, and $expand is currently limited to cardinality-one relationships.

$count=true

This means that the number of assets in the database is reported in the result. For example:

$skip and $top

Use these parameters to limit the quantity of returned records to manageable pages. By default, each query returns 50 results, as controlled by the $top parameter. For example, “$top=50&$skip=100” would skip the first two pages of 50 results and return the third page. Use the $count=true parameter to return the total number of records so that you can keep track of pages.

Other Query Parameters

$filter – limits the results returned. For example, “$filter=HasAnAlarm eq true” returns only indicators in alarm.

$Orderby – sorts the results based on one or more fields, for example: “$orderby=DateAndTimeCreated desc” would sort the results with the most recently created objects at the top.

For a list of logical operators, string functions, and date functions supported, see The AssetWise Reliability OData API Swagger page.

Tip:       If you plan to contact Support because of a problem with a query, it’s helpful to include the trace ID for troubleshooting. In the Body section, select the Headers tab. Scroll down to “Traceid”. Send the Traceid value to Support.