Create REST Query (Classic)
This topic describes how to create a REST query.
Before you begin
- Log in to Operations Hub.
- Create the data source that you want to use in the query.
- Create an entity to specify the query response. The entity fields that you want to map with the query output parameters must contain the same names as the parameters.
- It is recommended that you add the environment variable
no_proxy
to System variables. Additionally, include references tolocalhost
and nodes that are targets of REST queries in System variables. Be aware that the environment variables are case-sensitive: the case of the environment variables for the data source target in Operations Hub should match the case used by the Historian Server. See troubleshooting note.
Procedure
-
In classic Operations Hub navigation menu, select
QUERIES.
The QUERIES workspace appears.
-
Select Add new query.
The New Query window appears.
-
Provide these details:
Field Name Description Name Enter a name for the new REST query. The name must contain at least one uppercase or lowercase letter. Type Select REST. Additional options for creating the REST query appear.
Description Briefly describe the purpose of the query. Entity Select the entity that will specify the query response fields. Note: When using a Historian data source, the Entity field will auto-populate with the entity associated with the Available API selected.Method Select the method of operation you want to perform on the database using this query. Supported methods are: GET
: This method is used to retrieve data.PUT
: This method is used to update existing data.POST
: This method is used to add data.DELETE
: This method is used to remove data.
Raw Response Select this check box if you want to get either the entire JSON response or XML response mapped to a single entity field. You can then access the response by referencing that entity field while designing an application. If you clear this check box, individual components of the response are mapped to individual entity fields. Data Source Select the data source that you want to use for the query. Available API Select the API that you want to use in the query. This box contains a list of APIs that are available in the data source that you have selected. The list of available APIs will be filtered based on the method selected.
Note: Pre-existing APIs are available only for Historian data sources. For more information see Historian API help.Base URL, Query URL The Base URL and Query URL fields are populated with the base portion (that is, the host name or IP address of the data source server) and the remaining portion of the URL. The values in these boxes together identify the complete URL endpoint. The Base URL box is always disabled. The Query URL box is disabled if you select an API for a Historian data source. If, however, you are using a custom data source, you can enter a value in the Query URL box. Next, you need to create parameters as needed for the API you are querying. Each parameter will require a default or test value if you wish to run the query with the Execute button. -
Specify Path Parameters.
Identify the parameters in the path of the endpoint. These appear before the query string if query parameters are present.Example: For the endpoint
https://jsonplaceholder.typicode.com/users/1/posts
, the parameter betweenusers
andposts
, which is the user ID, is the path parameter. The value for this parameter is 1. -
Specify Query Parameters.
Identify the parameters in the path of the endpoint that appear after the question mark (?).Example: For the endpoint
https://jsonplaceholder.typicode.com/posts?userId=1
,userId
is the query parameter. The value for this parameter is 1. -
Specify Header Parameters.
Identify the parameters that you want to include in the request header. Typically, these parameters are related to authorization.
-
Specify Body Parameters.
This section appears when you select the
POST
method (refer to step 3 in this topic).Identify the parameters in the body of the request. Typically these will be required for PUT and POST methods, although they are sometimes required for DELETE as well.Body parameters can be supplied in Operations Hub as a URL encoded format, raw JSON, or raw XML. In case JSON or XML is selected, the first parameter should be used to supply the full JSON body. Subsequent parameters can be used for dynamic substitution into that JSON body.- JSON: If selected, the subsequent parameters should be JSON keys found in the body. The corresponding JSON values will be substituted.
- XML: If selected, the subsequent parameters should be strings
found in the body. These strings will be substituted. You can also
supply curly braces to delineate the parameters from text within the
body. For example,
{{STRING_TO_SUBSTITUTE}}
Be aware that the following Historian REST queries require the multi-select input to be enabled on the EndApp page for output data to be displayed:- Get > Raw Data
- Get > Calculated Data
- Get > Interpolated Data
- Post > Raw Data
- Post > Calculated Data
- Post > Interpolated Data
-
In the Execute section, select Run Request.
The query output fields, as well as the query appear in the Results box.Important: Provide sample values leading to a successful response in order to properly test the REST endpoint. We strongly recommend using values you know will return a representative set of data; otherwise, an error occurs or the response may not return the field data that you need. For example: for Historian data queries, if the set of requested tags is different from the returned set of data (that is, if one or more tags does not have data), the call will fail. The user should modify the inputs to include only the tags for which they are confident there will be data in the response. For PUT/POST/DELETE, this action is not a test but an actual request which can change your data.
- If required, select Create entity from results from Results. This will create an entity with the appropriate output fields generated from the previous Run Request.
-
Under the Output Data section, you can include one or
more output data fields to your REST query.
Following output fields are available to use:
Output Data Field Description TagName
This field represents the tag name you want to query in the database. Timestamp
This field represents the timestamp associated with each data point. Value
This field represents the actual data value associated with the specified tag at a given timestamp. Quality
This field represents the quality of the data at a specific timestamp. DataAttributes
This field represents data attributes associated with the data point. Historian is now enhanced to store up to 128-bit quality types, which are stored in data attributes. These attributes are extended qualities that you can store more than the regular qualities and sub qualities such as good and bad. In addition to regular qualities, the HAB collector collects extended qualities such as replaced, suspect, garbage, old, and so on. You can use these attributes using REST APIs as well as Configuration Hub.
Select next to the output data field you do not want to include in your query.
-
Save the REST query.
Save Saves the data. Save and Exit Saves the data and exits the screen.
Results
settings.conf
file in the following folder:
C:\ProgramData\GE\Operations Hub\iqp-config\IQP\app
. Use the
following command so that the slower REST requests do not hold up the Operations Hub
server. You can change the seconds value to increase the timeout setting further:
#REST client timeout (seconds)
rest_timeout=30
Some users may encounter a
502 error when attempting to use a REST query after adding no_proxy
and localhost
settings. This issue may not affect all users.
no_proxy
settings and
ensure that the host name you are using is correctly configured.- Open Control Panel and navigate to .
- Look for the
no_proxy
variable under System variables section.
To resolve this issue, add the actual name of the host. For example, if
localhost
causes trouble, try using the actual computer name
(e.g., Joe's PC). Restart the services after making these changes. Note that while
some users may encounter this issue, others may not experience any trouble with
using localhost
.