Query parameters not appended

I have tried running the code as given in the katalon docs link below but it does not seem to append the query parameters.

Here is script which is in the above link too.  Adding a statement like println requestObject.restUrl shown url without query params and the response contains data for all ids, instead of id requested. 

Can someone please take a look? Thanks!


import com.kms.katalon.core.testobject.ConditionType as ConditionType
import com.kms.katalon.core.testobject.RestRequestObjectBuilder
import com.kms.katalon.core.testobject.TestObjectProperty as TestObjectProperty
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

'Create a new GET object using builder'
def builder = new RestRequestObjectBuilder()
def requestObject = builder
	.withRestRequestMethod("GET")
	.withRestUrl("http://jsonplaceholder.typicode.com/comments")
	.withRestParameters([
		new TestObjectProperty("postId", ConditionType.EQUALS, "1"),
		new TestObjectProperty("id", ConditionType.EQUALS, "1")
	])
	.withHttpHeaders([
		new TestObjectProperty("Content-Type", ConditionType.EQUALS, "application/json")
	])
	.build()

//HERE ---- println requestObject.restUrl  does not show the query params
'Send a request'
def response = WS.sendRequest(requestObject)

'Verify if comment\'s email after sending request is correct or not'
WS.verifyElementPropertyValue(response, '[0].email', 'Eliseo@gardner.biz')

//HERE – response contains all ids instead of expected filtering by id

Hi @jmz

By default, the rest parameters are not appended to the URL, so as to keep these properties separate and easy to assemble when needed. Please try to use

RestfulClient.processRequestParams(requestObject)

and the URL inside the object will be replaced with one that has the rest parameters.

Thank you!
I’ve tried this and it now sends the query params appended to the URL.

1 Like