Skip to content
Sahi Pro Flowcharts is retired. These pages document the last release (v12) and are no longer updated. Go to the current documentation.Flowcharts is retired. Current docs
Get Free Trial
Sahi Pro Flowcharts is retired. These pages document the last release (v12) and are no longer updated. Go to the current documentation.

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.

  1. Click on the node where you need to add REST API call on the flowchart and select Automate.

  2. Automate dialog opens up with the selected node.

  3. Click on the icon near to Add Step and from the drop-down select REST API Call

    Add Step

  4. It opens a REST API dialog with the options to call GET, POST, PUT, DELETE, PATCH

  5. Choose relevant call, ex. GET and complete the fields like URL, Headers, etc

  6. Click Get Response to get the response of API

    Call REST API

  7. It will automatically navigate to the Response tab and show the response of the API.

  8. Click on the TREE under Body tab.

  9. Click on the checkboxes for the values that need to be asserted or stored.

    Response Assert

  10. Click on the Update to save the assertion.

    Save assertion

  11. Click on Store to store the value of the response in some variable.

    Store Variable

  12. Assertions can be seen on Assertions tab

    Assertions Tab

  13. Variables can be seen on Variables tab

    Variable Tabs

  14. Click on Update button to add the API Call in the Keyword.

    REST API Call

  15. Similarly, use Post or any other method.

    Post Example

  • Follow below steps to import requests directly from the Postman API Platform:

    1. Launch Postman, open the Postman console (press Ctrl+Alt+C for Windows OS or Command+Option+C for macOS), clear the console, and execute the REST API call to generate a log.

    2. Click on the Copy all logs to clipboard button to copy the log from the console.

      Copy all logs to clipboard

    3. In the REST API dialog, click the Import from Postman button.

      Import From Postman Example

    4. Paste the copied Postman’s console log into the textarea and click the Import button.

      Import From Postman Dialog

    5. This will populate the corresponding fields in the Request tab.

      After Importing From Postman

  • Click on the drop-down arrow on Import from Postman dialog and click on Import request from HAR button.

  • Paste the request section of the response to be validated from HAR logs and click on Import

REST Response section displays following information:

  1. Response Status: Displays the response code returned by the server.
  2. Response Header: Displays the response headers returned by the server.
  3. 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 can be added through following methods:

  1. On the Response tab, click on the Assert button next to the response values for assertion.

    • The Assert button will be visible only on hovering on any value.

    Response tab - Assert button

  2. The Add Assertion dialog opens up. Select the relevant assertion type and click on Update

    Add Assertions dialog

  3. Multiple assertions can be set simultaneously using the checkboxes to select and then click on Assert button at the bottom.

    Add Multiple Assertions

  4. The added assertions can be seen on the Assertions tab.

    Added Assertions

  5. Assertions can also be added from the Assertions tab by clicking on the New Assertion button at the bottom.

    Add New Assertion

  6. An assertion can be edited by clicking on the Edit icon next to it.

    Edit Assertion

The values can be stored in variables through following methods:

  1. On the Response tab, click on the Store button next to the response values to store the value on the variable.

    • The Store button will be visible only on hovering on any value.

    Response tab - Store button

  2. The Store Value dialog opens up. Type the variable name preceding with a $ symbol and click on Update.

    Store Value dialog

  3. Multiple response values can be stored simultaneously using the checkboxes to select and then click on Store button at the bottom.

    Create Multiple Variables

    • When multiple variables are created together, the variable names will be taken automatically.
  4. The added variables can be seen on the Variables tab.

    Stored Variables

  5. Variables can also be created from the Variables tab by clicking on the New Variable button at the bottom.

    Create New Variable

  6. A variable can be edited by clicking on the Edit icon next to it.

    Edit Variable

Enter the username and password after selecting Basic Auth from dropdown.

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.

Input

Description

Example

File name

Absolute file path to the file that should be provided.

https://sahitest.com/demo/php/fileUpload.php

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

OS

OS Dependent path example

Windows

C:\Users\user\Desktop\upload.txt

macOS

/Users/user/Desktop/upload.txt

Linux

/home/user/Desktop/upload.txt

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:

  1. Open REST API Call dialog by clicking on the Add Step drop down menu.

  2. Select the POST from HTTP Method combo box.

  3. Specify the file upload URL in the URL field.

  4. Specify the Content-Type header in the HTTP Headers field.

    HTTP Headers in REST API Call

  5. Select the Parameterized radio button for Body field and specify the file path or any other body parameters if required.

    Body Parameters in REST API Call

  6. Click on the Get Response button.

  7. You will get the following result after the file upload, the response may differ depending on the web application

    File Upload Response in REST API Call