top of page
Search

Getting started with Rest API testing

What is Rest API?

REST stands for Representational State Transfer. It is a software architecture style that relies on a stateless communications protocol, most commonly, HTTP. REST structures data in XML, YAML, or any other format that is machine-readable, but usually JSON is most widely used.


Testing with Rest is basically sending different requests to REST API and validating the responses. Let's get started.


Anatomy of Rest Request:


Rest Request is made of following important parts,

  1. Endpoint

  2. Method

  3. Header

  4. Data

1. Endpoint:

The Endpoint if the URL you use to send request. In our example, the endpoint is

https://petstore.swagger.io

2. Method:

The method is the type of request you send to the server. These methods provide meaning for the request you’re making. They are used to perform four possible actions: Create, Read, Update and Delete (CRUD).


3. Header:

Headers are used to provide information to both the client and server. It can be used for many purposes, such as authentication and providing information about the body content. You can find a list of valid headers on this link.


HTTP Headers are property-value pairs that are separated by a colon. The example below shows a header that tells the server to expect JSON content.


"Content-Type: application/json"

4. Data:

The data (sometimes called “body” or “message”) contains information you want to be sent to the server. This option is only used with POST, PUT or DELETE requests.


Create First Rest Request:

Start by creating a new REST project with a single request,


1. You can download and import sample Rest projects from the Welcome page, which opens when we start soap UI.


Or we can use wadl to create new rest project by selecting File > New Rest Project.

In the dialog box, enter the following URL and click OK.


https://petstore.swagger.io/v2/pet/findByStatus?status=available

Soap UI creates the project complete with a Service, Resource, Method and the actual Request and opens the Request editor.

2. In the request tab, click on the green play button to see the JSON response displayed for the REST request.

3. To create a Test case, right click on the request -> Add to test Case -> Enter Test Suite Name -> Test Case Name and enter OK.





4. Click on the green play button, we can see JSON response for the request.

Thus we created our First test case for REST API. Happy Testing!

12 views0 comments

Recent Posts

See All

Minimum Deletions to Make Character Frequencies Unique

A string s is called good if there are no two different characters in s that have the same frequency. Given a string s, return the minimum number of characters you need to delete to make s good. The f

Smallest String With A Given Numeric Value

The numeric value of a lowercase character is defined as its position (1-indexed) in the alphabet, so the numeric value of a is 1, the numeric value of b is 2, the numeric value of c is 3, and so on.

bottom of page