InvokeREST
You use the InvokeREST keyword to test and issue REST API calls from within a test script. Using the InvokeREST keyword (for example, to execute the API, verify and/or use the response) reduces the complexity and effort required in automating REST APIs and integrations for automated testing. Note the following:
-
For REST API calls over HTTPS, Application CA certificate must be imported into Java's default truststore (cacerts). Sample command to complete the step:
<JAVA_HOME>\bin\keytool -import -file <PATH_TO_CERTIFICATE_FILE> -alias "<Alias>" -keystore "<JAVA_HOME>\lib\security\cacerts"
Replace
JAVA_HOME
with JRE install location andPATH_TO_CERTIFICATE_FILE
should be replaced with CA certificate file location(for example: C:\DISA\jre). You may provide a name for the certificate by replacing<Alias>
.For information related to certificate import/truststore, refer to section, Communications Encryption in Siebel Security Guide.
-
InovkeREST Test Step can be added before a Launch Test Step. The REST URI alias in InvokeREST appears in Test Execution Server Credentials applet as Application Alias.
-
Provide REST Server details in the Test Execution record against the REST URI Alias in the "Server Credentials" applet
url: https://servername.com:port number/...
, and specify the password in the Users applet against the correct user id.Ensure the Application Type is set to
REST_URI
from drop-down. If the valueREST_URI
is missing, add or activate in Administration - Data → List of Values View. -
For a unit run (Play button on Test Script applet), update unitconfig.xml in DISA folders with following attributes and appropriate values within OPTIONAL_PARAM node.
Example:
<APPLICATIONS> <APPLICATION> <APPLICATION-ALIAS>REST URI Alias</APPLICATION-ALIAS> <APPLICATIONTYPE-BROWSER>REST_URI</APPLICATIONTYPE-BROWSER> <URL>https://hostname:portname/siebel/v1.0</URL> <SERVER-OS-TYPE>Windows</SERVER-OS-TYPE> </APPLICATION> </APPLICATIONS> <USERS> <USER> <USERID>User_Name</USERID> <PASSWORD>Password</PASSWORD> </USER> </USERS>
For multiple user IDs usage in InvokeREST keyword, USER node within USERS can be repeated.
Signature
The InvokeREST keyword supports the following signature:
InvokeREST(HTTP Method Name:URL_Alias, UserId|REST_Resource, Input JSON file name | values to be replaced in request body (comma separated); NULL, REST Response code to verify / One variable name or comma separated list of variables.)
The following table describes how to use the InvokeREST keyword to test and issue REST API calls from within a test script.
Target Object | Inputs | Closing Action | Comments |
---|---|---|---|
GET / POST / PUT / DELETE; <REST URI Alias, userid> | REST Resource |
Input JSON file name | values to be replaced in request body (comma separated); NULL |
REST Response code to verify / One variable name or comma separated list of variables. Note: Variable names must match the field names in the REST response.
If the field name contains space, variables name must be enclosed within quotes, for
example: @"variable with space"
|
Issues the REST API call and uses the Response to verify the response code and/or read values into variables. |
Pre-defined and Auto-generated Variables for using or validating EAI/REST Response:
Assuming JSON response structure for REST API, Keyword framework provides few pre-defined variables and generates new variables based on the response. It is important to note that the predefined and auto-generated variables (if repeating) are reinitialized or overwritten with subsequent InvokeREST call. Hence, ensure to use the values prior to subsequent InvokeREST call.
-
@StatusCode
: Typically used in closing action to validate REST Response Code. For example,StatusCode:200
in closing action will ensure that framework validates the response code to be 200. -
@Errormsg
: If provided during closing action, keyword framework can capture the error message for the cases when REST API returns so. -
@resp
: The complete response from InvokeREST is captured with this predefined variable. -
Fetching property values from JSON into Variables: Variables if provided in Closing Action, are matched with the property names of JSON response and their values are updated accordingly. For example, if
@Name
is provided in Closing Action, keyword framework will look-up the top-level JSON response for Name property and copy the property value to the variable @Name.
Example 1
InvokeREST keyword Example 1 is shown in the following table.
InvokeREST Keyword | Example |
---|---|
Target Object |
Method to Invoke: REST Resource: |
Inputs |
Request Body: NULL Work space name/Any Search Spec: NULL |
Choice of Closing Action |
End Action: |
In this example, using the InvokeREST
keyword, you may make an API request
"data/Account/Account/88-347S25/Account Attachment?inlineattachement=True"
and
capture the property AccntFileSize and Acct Attachment Id from the response in variable as
@AccntFileSize
and @"Accnt Attachment Id"
.
The API request method is GET and the REST URL alias is provided using NEW_REST (any name of your choice, but without spaces). In the Test Execution record, Server Credentials applet will be populated with NEW_REST and you may update the REST URL appropriately. Please note that the complete REST URL will be formed by concatenating REST URL and REST Resource provided with InvokeREST keyword.
{
"AccntFileSize":"89",
"AccntFileName":"Test5555",
"Comment":"",
"Account Id":"88-347S25",
"Id":"88-347S2Z",
"AccntFileDate":"09/21/2022
01:54:10",
"AccntFileDockStatFlg":"E",
"AccntFileSrcType":"FILE",
"AccntFileAutoUpdFlg":"Y",
"AccntFileDockReqFlg":"N",
"AccntFileExt":"txt",
"AccntFileDeferFlg":"R",
"AccntFileSrcPath":"",
"Accnt Attachment
Id":"QXR0YWNobWVudCBmb3IgZGVtbw==",
"Link":[
{
"rel":"self",
"href":"https://asdfjkl:16690/siebe
l/v1.0/data/Account/Account/88-347S25/Ac
count Attachment/88-347S2Z",
"name":"Account Attachment"
},
{
"rel":"canonical",
"href":"https://asdfjkl:16690/siebe
l/v1.0/data/Account/Account/88-347S25/Ac
count Attachment/88-347S2Z",
"name":"Account Attachment"
},
{
"rel":"parent",
"href":"https://asdfjkl:16690/siebe
l/v1.0/data/Account/Account/88-347S25",
"name":"Account"
}
]
}
Example 2
InvokeREST keyword Example 2 is shown in the following table.
InvokeREST Keyword | Example |
---|---|
Target Object |
Method to Invoke: REST Resource: |
Inputs |
Request Body: Work space name/Any Search Spec: |
Choice of Closing Action |
End Action: Note: @"items:Account Attachment:Id" indicates the hierarchy in JSON response i.e., Id is
child of Account Attachment which in turn is child property of
items.
|
Content of Attachment.json
:
{
"AccntFileName":"Test$,
"AccntFileExt":"txt",
"Accnt Attachment Id":"QXR0YWNobWVudCBmb3IgZGVtbw"
}
Ensure to place input JSON file (i.e. Attachment,json in this case) in the resources/invokerest folder (ensure same folder structure in your Resources.zip attachment to Master Suite).
Example 2 Output Response:
{
"items":{
"Id":"88-347S25",
"Account Attachment":{
"Id":"88-347S2Z",
"Accnt Attachment Id":"https://asdfjkl:16690/siebel/v1.0/data/Account/Account/88-347S25/Account Attachment/88-347S2Z?fields=Accnt Attachment Id",
"Link":{
"rel":"self",
"href":"https://asdfjkl:16690/siebel/v1.0/data/Account/Account/88-347S25/Account Attachment/88-347S2Z",
"name":"Account Attachment"
}
},
"Link":{
"rel":"self",
"href":"https://asdfjkl:16690/siebel/v1.0/data/Account/Account/88-347S25",
"name":"Account"
}
}
}
Example 3
InvokeREST keyword Example 3 is shown in the following table.
InvokeREST Keyword | Example |
---|---|
Target Object |
Method to Invoke: REST Resource: |
Inputs |
Request Body: Work space name/Any Search Spec: |
Choice of Closing Action |
End Action: |
Content of data_POST.json
:
{
"Name": "InvokeREST_Data_$",
"Primary Organization": "Millennium Institutional Finance Services IF ENU",
"Location": "HQ-Distribution",
"Description": "@var1",
"Primary Organization Id": "1-1DG"
}
It is important to note that variable support is present with JSON file as well and keyword
framework will make attempt to replace content as required. For example, $
with
InvokeREST_Data_
will be replaced with timestamp
. Similarly,
@var1
will be replaced appropriately, provided the value is defined.
{
"items":{
"Name":"InvokeREST_Data_10212022_032608182",
"Id":"88-347S25",
"Location":"HQ-Distribution",
"Primary Organization Id":"1-1DG",
"Primary Organization":"Millennium Institutional Finance Services IF ENU",
"Description":"AccountData",
"Link":{
"rel":"self",
"href":"https://asdfjkl:16690/siebel/v1.0/data/Account/Account/88-347S25",
"name":"Account"
}
}
}
Example 4
InvokeREST keyword Example 4 is shown in the following table.
InvokeREST Keyword | Example |
---|---|
Target Object |
Method to Invoke: REST Resource: |
Inputs |
Request Body: Work space name/Any Search Spec: |
Choice of Closing Action |
End Action: |
{}
Example 5
Using the API /data/Quote/Quote, insert a record in Quotes using the method POST and fetch following Name, Primary Organization, Quote Number and Revision in variables from the response.
InvokeREST Keyword | Example |
---|---|
Target Object |
Method to Invoke: REST Resource: |
Inputs |
Request Body: Work space name/Any Search Spec: |
Choice of Closing Action |
End Action: |