Automate REST API Calls
As part of a test flow, we may need to call some webservice via REST APIs. The REST API Call Step in Flowcharts allows calling and verifying REST API calls.
REST Request
Section titled “REST Request”-
Click on the node where you need to add
REST API callon the flowchart and selectAutomate. -
Automatedialog opens up with the selected node. -
Click on the icon near to
Add Stepand from the drop-down selectREST API Call
-
It opens a
REST APIdialog with the options to callGET,POST,PUT,DELETE,PATCH -
Choose relevant call, ex. GET and complete the fields like
URL,Headers, etc -
Click
Get Responseto get the response of API
-
It will automatically navigate to the
Responsetab and show the response of the API. -
Click on the
TREEunderBodytab. -
Click on the checkboxes for the values that need to be asserted or stored.

-
Click on the
Updateto save the assertion.
-
Click on
Storeto store the value of the response in some variable.
-
Assertions can be seen on
Assertionstab
-
Variables can be seen on
Variablestab
-
Click on
Updatebutton to add theAPI Callin the Keyword.
-
Similarly, use
Postor any other method.
Import from Postman
Section titled “Import from Postman”-
Follow below steps to import requests directly from the
PostmanAPI Platform:-
Launch Postman, open the Postman console (press
Ctrl+Alt+Cfor Windows OS orCommand+Option+Cfor macOS), clear the console, and execute the REST API call to generate a log. -
Click on the
Copy all logs to clipboardbutton to copy the log from the console.
-
In the
REST APIdialog, click theImport from Postmanbutton.
-
Paste the copied Postman’s console log into the textarea and click the
Importbutton.
-
This will populate the corresponding fields in the
Requesttab.
-
Import from HAR
Section titled “Import from HAR”-
Click on the drop-down arrow on
Import from Postmandialog and click onImport request from HARbutton.
-
Paste the request section of the response to be validated from HAR logs and click on
Import
REST Response
Section titled “REST Response”REST Response section displays following information:
- Response Status: Displays the response code returned by the server.
- Response Header: Displays the response headers returned by the server.
- Response Body: Response Body has 3 tabs:
-
Raw: Displays the response body as it is returned.

-
HTML: Displays the parsed HTML if content-type returned from server is HTML.

-
TREE: Displays the response body in tree structure if content type returned from server is JSON or XML.

-
Assertions
Section titled “Assertions”Assertions can be added through following methods:
-
On the
Responsetab, click on theAssertbutton next to the response values for assertion.- The
Assertbutton will be visible only on hovering on any value.

- The
-
The
Add Assertiondialog opens up. Select the relevant assertion type and click onUpdate
-
Multiple assertions can be set simultaneously using the checkboxes to select and then click on
Assertbutton at the bottom.
-
The added assertions can be seen on the
Assertionstab.
-
Assertions can also be added from the
Assertionstab by clicking on theNew Assertionbutton at the bottom.
-
An assertion can be edited by clicking on the
Editicon next to it.
Variables
Section titled “Variables”The values can be stored in variables through following methods:
-
On the
Responsetab, click on theStorebutton next to the response values to store the value on the variable.- The
Storebutton will be visible only on hovering on any value.

- The
-
The
Store Valuedialog opens up. Type the variable name preceding with a$symbol and click onUpdate.
-
Multiple response values can be stored simultaneously using the checkboxes to select and then click on
Storebutton at the bottom.
- When multiple variables are created together, the variable names will be taken automatically.
-
The added variables can be seen on the
Variablestab.
-
Variables can also be created from the
Variablestab by clicking on theNew Variablebutton at the bottom.
-
A variable can be edited by clicking on the
Editicon next to it.
Authorization
Section titled “Authorization”Basic Auth
Section titled “Basic Auth”Enter the username and password after selecting Basic Auth from dropdown.

OAuth 1.0:
Section titled “OAuth 1.0:”Choose OAuth 1.0 from the Authorization dropdown.

-
Credentials: Select an already saved credential or type a new credential to add a new one.

Enter a friendly name to save these credentials against. Enter the
Consumer Key, Consumer Secret, Token, Token Secret. These details are provided by the API provider. -
Signature Method: Sahi currently supports HMAC-SHA1 and HMAC-SHA256 signature methods.
-
Version: Enter the version as required by the API under test.
-
Realm: Enter the realm as required by the API under test.
Uploading a file using REST API Call
Section titled “Uploading a file using REST API Call”Input | Description | Example | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
File name | Absolute file path to the file that should be provided. | |||||||||
File upload URL | The URL where you want to upload the file. This URL is usually the action URL which is present in the form response values or URL that is passed as an argument for an XML Http Request |
| ||||||||
Content Type | Content type of the POST data that is being sent. The content type for the file upload is multipart/form-data and is being used by all the browsers. There are special cases where you can specify your own content type | Content-Type: multipart/form-data; boundary=--boundary123456abcd | ||||||||
Boundary | A random string with 2 hyphens at the beginning | --boundary123456abcd |
Steps:
-
Open
REST API Calldialog by clicking on theAdd Stepdrop down menu. -
Select the POST from
HTTP Methodcombo box. -
Specify the file upload
URLin the URL field. -
Specify the Content-Type header in the
HTTP Headersfield.
-
Select the
Parameterizedradio button forBodyfield and specify the file path or any other body parameters if required.
-
Click on the
Get Responsebutton. -
You will get the following result after the file upload, the response may differ depending on the web application


