How to Set Query Parameters in WebService Request

Hi,

I have Created the Web Service Test Object [SearchReport] under Object Repository and created two Parameters let say [Param1,Param2].

I created Testcase[TestSearch] with Test Step WebServiceKeyword, i can see only sendrequest keyword.

Can you let me know how to set values for Param1 & Param2 and how to send them has Query parameters not has Post body parameters?

Thanks, it means we have to write this in testcase and execute it.

Is there a way to set Global variable in Test Objects itself instead of writing separate testcase.

I want Param1 & param2 to be passed as query parameters with using Global Variables in test object.

Hi there,

The current design of Test Object doesn’t have any ability to do this. You have to pass in from test case.

Thanks

Hi there,

Here is the example you can follow:

'Add REST parameter using local variable from Variables tab'
RequestObject request = findTestObject('REST_CommentDetails')
request.getRestParameters().add(new TestObjectProperty('param1', ConditionType.EQUALS, GlobalVariable.param1))
request.getRestParameters().add(new TestObjectProperty('param2', ConditionType.EQUALS, GlobalVariable.param2))

'Send a REST request and returns its response'
def response = WS.sendRequest(request)

So you can use APIs to help you adding custom parameters usng Global Variables to the request object. Please refer to API page for more details.

Hi there,

I don’t clearly understand your question. What do you really want with that web service test object by using param1 & param2?

Thanks