Do not follow redirects when using RequestObject and ResponseObject


I’m testing our website’s 301 redirects and need a way to get the status code of a ResponseObject without it actually following the redirect itself (i.e. I’m expecting a status code of 301 instead of 200).

Here is a sample of my script:

import com.kms.katalon.core.testobject.RequestObject
import com.kms.katalon.core.testobject.ResponseObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords
import com.kms.katalon.core.logging.KeywordLogger

String url = ''
String urlResponse

RequestObject ro = new RequestObject()
ResponseObject resp = new ResponseObject()
KeywordLogger log = new KeywordLogger()

resp = WSBuiltInKeywords.sendRequest(ro)
urlResponse = resp.getStatusCode()


Of course you’d expect to return 200, but pretend the URL has a 301 redirect set up to forward the user to a different page – in this scenario, Katalon will actually follow the redirect and return the status code based on the destination page, rather than returning a 301 status code from the source page.

Postman allows this by turning off the ‘automatically follow redirect’ setting. I’m wondering if there’s a particular method I can call on the RequestObject or ResponseObject in order to achieve this in Katalon too.


It is a nice suggestion.