Create REST API requests manually


Katalon offers a great UI support for creating REST API requests. But if you are the advanced Katalon user, you can do it manually and benefit from a large library of Katalon support methods for API requests. This tutorial will be about how to create REST API requests from manual and handle responses to make your code robust and effective.


You should be familiar with Katalon Studio and know the basics of Java/Groovy.

RequestObject and ResponseObject

These are two main classes for handling API requests. I am sure you have already figured out that the RequestObject class represents an API request and the WSBuiltInKeywords.sendRequest method returns ResponseObject.

Now let’s create a REST API request as an example (of course, you can do the same with SOAP API requests). You first need to have information for a request, including

  • URL
  • Request method (GET, POST, PUT, DELETE, …)
  • Request headers (Authorization, Content-Type, …)
  • Request body (for POST request)
  • REST request parameters

Next, you create an object from RequestObject using either one of the following ways:

  • New a RequestObject instance directly and set its information using setter methods such as setRestUrl() and setRestRequestMethod().
  • Use RestRequestObjectBuilder, a useful helper class offered by Katalon Studio version 5.4 and later.

As you can see, the source code includes two different ways to create a request. Both of them return a ResponseObject object. When using RestRequestObjectBuilder to create a RequestObject instance, you call withXXX() and build() methods.

One benefit of RestRequestObjectBuilder is that it has additional methods to allow directly setting different body types for POST requests such as FileBodyContent and MultipartFormBodyContent. It is possible also using RequestObject, but it is more straightforward with RestRequestObjectBuilder.

For further details on the methods of these classes, please visit RequestObject and RestRequestObjectBuilder on Katalon API Documentation website.

As a note, if you want to use HTTP headers, you can create new TestObjectProperty instances as shown in the code snippet.

Creating a POST request is basically the same as a GET request, but you must specify the request body using either setBodyContent from RequestObject or withTextBodyContent from RestRequestObjectBuilder.

There are many different types of request body such as file and form data body content. Please refer to RestRequestObjectBuilder API documentation to get a full list of its methods.


As you can see above, we get a ResponseObject instance when sending an API request. This object contains all information needed for a response, including status code, response body, response headers, waiting time and many others. Methods for handling response objects may look like this:

And sample usage in your test case:

You may wonder why the SampleResponseObject class is needed as I can get all information directly by calling the methods from the response object. This wrapper may be helpful for your future enhancements as your code is less dependent on the ResponseObject class. If there are changes to this class, you only need to update the wrapper class. It is up to you which approach you follow, but both of them are correct.


This tutorial was focused on advanced usage of REST API requests in Katalon. As I prefer writing code instead of clicking in Manual mode, this tutorial may be helpful to similar automation engineers as I am.

RequestObject and ResponseObject are powerful classes, which may help you to customize your API tests in details.

Rest API Request Katalon Studio


About the author

Marek Melocik is currently working as Test Automation Engineer in Brno, Czech Republic. He has been working in QA industry since 2014.

Meet Marek at

83% people found this helpful
Related testing tools
Katalon Studio
Best automation solution for software testing team. Completely free!
Katalon Recorder
Ultimate Selenium IDE to record, play, and debug app. Fast and extensible!
Katalon Analytics
Bring you to the next level of test execution reports. Smart and seamless solution!
Scroll up