Introduction
Hi there!
Did you know that before REST was developed, SOAP was used to integrate APIs? As SOAP was known to be complex to build and use, REST was created as a standard to facilitate communication between servers. In this blog, we shall discuss creating REST requests in Katalon Studio.
Creating a REST request through UI
Responses are received for every request sent to the API server. This section explains how to create a RESTful request using Katalon Studio's UI. RESTful requests in Katalon can be created by adding a Web service request to a New or Existing test case. The options are displayed by clicking on the plus icon at the top.
Request
Here is how you can create a new Web service request.
Step 1: After creating a new project, create a new web service request by going to Test Explorer -> Object Repository -> New -> Web Service Request.
Step 2: Type in the necessary details and click OK.
Step 3: Enter the request method, URL, and Authorisation.
Request method
Katalon Studio provides nine request methods that indicate the action to be carried out by request. They are:
-
GET - Search for a resource.
-
POST - Create and add a new resource.
-
PUT - Update an existing resource.
-
DELETE - Delete a particular resource.
-
PATCH - Partially update a resource.
-
HEAD - Request for headers.
-
CONNECT - Initiate two-way communication with a resource.
-
TRACE - Trace a message to the target resource.
-
OPTIONS - Request communication options.
The default method for all new requests is GET. We can also create a custom method by adding it in the Project > Settings > Test Design > Web Service > Custom Method window.
Request URL
The URL must be a service endpoint that receives the request. URLs can contain query parameters within their body, as shown below.
Query Parameters
They are embedded within the request object. They are used to find a resource specifically.
Request Body
It contains the information to be sent along with the request, especially for POST, PUT and PATCH. There are various options to set the request body.
Authentication
Authenticating and authorising requests is essential as it verifies the client's identity. An appropriate response is sent if the user authentication is successful. Katalon Studio displays five types of auth.
- Bearer - It requires security tokens called bearer tokens for authentication.
- Basic - It involves a username and password for verification.
- OAuth 1.0
- OAuth 2.0
- NTLM
Response View
The key information derived from a Response message is the Status code, Elapsed time and size of the response.
The response body contains the actual response received from the API server. We can view the response body in JSON, XML, HTML or JavaScript format.