Scriptworks Logo

REST - GET Request 200

12th May 2021 | API Testing Tutorials

banner resources

This Article covers HTTPS method GET, requests made to a REST API, and validation of the response through Scriptworks.

Introduction

We covered the basics of what a REST API is and how it works in our previous article. 

Let’s try to perform an exercise to validate the response received from an example REST API.

First, I will demonstrate the exercise we need to perform, followed by practically demonstrating the Automation through Drag and Drop of relevant Blocks present in Scriptworks for achieving it.

HTTP Method Discussed in this Article:-

GET:- HTTP Method GET is used to read or retrieve data from the URI end. 

HTTP Response Code Discussed in this Article:- 

200:- HTTP Status code 200 belongs to Success Category, which states that whatever request the user has requested through a client (or browser) has succeeded.

Note - Here, We are using https://reqres.in/ to practice on  REST API’s queries response validation. 

Exercise:-

 

1) Open any random browser, e.g. Chrome or Firefox.

Navigate to any browser

2) Navigate to https://reqres.in/

open reqres.in browser

3)  If the website has successfully loaded on the browser, then the response code will be 200

 

Practical Demonstration

Following are the Steps to Perform the above Exercise including validation using Low Code Visual Programming in Scriptworks:-

Pre-requisite: Users should be able to login to Scriptworks via their Credentials, and his Scriptworks Client should be up and running. 

To know more about Scriptworks Client and Selenium Standalone Server, please follow this Article.

1) Open Scriptworks on your system with your credentials and open the project where you want to perform the Automated validations on the REST API response.

open scriptworks with REST_API_Samples_Project

2) Now click on the Block symbol present on the left side panel and then click on getting started 

BlockSymbol → Getting Started → API Test

As we know, we are going to initiate an API test. So Drag and Drop “API Test” onto the Canvas After clicking on the Getting Started link.

look for getting started link

select api test block

Putting API Test Block into the Canvas

3) Now, we will use the comment block to let others know what we will perform. For that, we are going to click on the search text box and write comment and hit return.

Search → Comment → Drag and Drop to Canvas

Search for block you need in search box

 

Fill the comments and put it into canvas

4) Now, we will drag and drop some basic blocks required for a REST API request. 

For REST API Request, we need four basic things from Scriptworks. 

i) REST Call Block

ii) Method Block

iii) URI Block

iv) Response Block 

We have searched the comment block in step 3 similarly we have to do for required blocks and drag and drop them to canvas.

  1. Search → REST Call → Drag and Drop to Canvas
  2. Search → Method → Drag and Drop to Canvas
  3. Search → URI → Drag and Drop to Canvas
  4. Search → get Response → Drag and Drop to Canvas

Demonstrating Drag and Drop of Rest call Block to Canvas

search for rest call block in search box

Put Rest Call Block inside the canvas

Demonstrating Drag and Drop of Method Block into Canvas

search for method block into the search box

Demonstrating Drag and Drop of URI Block into Canvas

search for uri block in the search box

putting URI Block into the canvas

In URI Block Enter “https://reqres.in/

Enter URL inside the URI Block

Demonstrating Drag and Drop of get response Block into Canvas

search get response block from search box

5) Let’s give it a dry run and see what we are receiving in the response after the run.

Request details with request headers

In the above screenshot, we can see the request we have sent to the REST API with the request headers that have been passed.


In the above screenshot, we can observe how Scriptworks is reporting the REST API response.

6) Drag comment to let others know what we are going to do now. And for that, follow Step 3 Above.

Search → Comment → Drag and Drop to Canvas

Put validate response inside the comments and in canvas

7) Now, to validate the response, or we can say in technical terms, i.e., to Assert the API response received by Scriptworks. Drag the Assert block multiple times to the number of Assertions you want, put it in Canvas, and fill it with information you wish to assert from the Rest API response.

Search → Assert → Drag and Drop to Canvas

search assert from the search box

put mulitple assert block inside the canvas

We have added the Assert Blocks. Now, what do we have to Assert? 

We have to Assert the status code and status message from the API Response. The further Response properties are available alongside the Response body. So search for the response in the search box and pick the response body block and drag it into the canvas, selecting the property we wish to validate.

Search → Response → Drag and Drop Response Body into Canvas 

search response block from search box

8) Now, the final thing is Test Run. Make sure you have followed the prerequisite mentioned above before the Test Run. Make sure you can see Green Symbol before clicking on the play icon.

highlighting play icon and client icon

Pass for rest api get response

That’s how we can validate a REST API request and its response code and status message in Scriptworks.

<<Previous Post                  Next Post>>

Other resources you might be interested in...

Scriptworks logo
© Copyright 2021 | Scriptworks is part of Odin Technology Ltd, a company registered in England no. 03735083