SoapUI API Automation - Part 3 - Requests

In this blog series, I will help you become an accomplished API automation engineer. Last created our first Rest API Project in the SoapUI application. Part 3 is about adding Requests to your SoapUI project.

If you don’t have SoapUI you can download it here.
View all posts from the series here.

Web Hosting

Set up the project

Last time we created our project it gave our Project default values. Let’s do a little cleanup and give things more appropriate names.

Update your project files so that it looks like this. Hint: Right click on each item and choose “Rename”.

Updated Project Names

API Documentation

In order for us to start working on the requests, we need to check the API documentation for the parameters that they are expecting. Find the API documentation of the PokeApi here.

According to the documentation, “Calling any API endpoint without a resource ID or name will return a paginated list of available resources for that API.” The request is a “GET” and the resource is “api/v2/{endpoint}”. Let’s see what this means by example.

Rest Request Editor

Double click on the “All Resources” request that we made. You should see the Rest Request Editor open. Let’s take a quick look at the parts of the Rest Request Editor.

Request Editor

Starting from the top. Note: I’m only going to list out the items that are important for this tutorial.

Play / Stop Buttons: You can try out your requests.
Method: You can specify the method type here. We will only be using the “GET” method.
Endpoint: This is your Rest Service.
Resource: This is your resource path.
Request Editor: The left side is the Request Editor. Here you can add or remove parameters.
Response Editor: The right side is the Response Editor. Here you can see the response in a few different formats. For this tutorial, we care about the JSON and RAW formats.

Add parameters to the request

  1. Click the green + button in the Request Editor. You will see a new line appear.
  2. Enter “endpoint” into the Name field. Note: Remember from the documentation the resource is “api/v2/{endpoint}”.
  3. Change the Style to “Template”.

Your parameter should look like this.

Rest Parameter

A couple things to note. First, there are two types of style that we care about for this tutorial. Query and Template.

Query Style is a request that uses query string parameters. For example, a request would look like “api/v2?number=1”. Notice the question mark? That question mark marks the start of the query string. The query string is going to have a key-value pair. The key is the parameter being passed in, the number for this example. The value is the value being passed in, so “1”. So the request sets a number value of 1 when it is made.

Template Style is a request in the format of “api/v2/{endpoint}”. The parameter is appended to the end of the resource. So it would look something like “api/v2/1/”.

Play the request

You are now ready to play the request. Hit the green play button. On this right side click the JSON tab. You will see a list of Resources in JSON format. Not click the Raw tab. Here you will see the same information but you will also see the HTML headers.

Congrats! You have just made your first Rest API Request.

Next: More Resources & Requests



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.