Set parameters for GET REST API call through GlobalVariable

I am unable to set REST parameters value runtime for GET call. I am trying as below. Please suggest the correct one.

RequestObject reqObj = findTestObject(‘Object Repository/UNLOCK GET ORDERS’)

reqObj.setRestUrl(GlobalVariable.restURL)

reqObj.getRestParameters().add(new TestObjectProperty(‘searchString’, ConditionType.EQUALS, GlobalVariable.param))

reqObj.getRestParameters().add(new TestObjectProperty(‘fields’, ConditionType.EQUALS, GlobalVariable.param))

def getResponse = WS.sendRequest(findTestObject(‘UNLOCK GET ORDERS’))

WS.containsString(getResponse, ‘OrderDetails’, false)

PN: Refer attached images.

API error.png

Abhijit,

Is there any information on how do you know that the parameters could not be set correctly?

It returns some junk value when print the value of reqObj.getRestParameters() on console

could you paste me the whole ‘param’ value, I would like to debug it.

param is list variable. Here are the values
{“fromDate”:“23-Jan-2018”,“toDate”:“23-Jan-2018”,“searchSource”:“UI”}
{“orderDetails”:[“order”], “order”:[“customerOrderNumber”,“acceptedDate”,“account”,“groups”], “account”:[“names” ,“details”,“additionalDetails”],“groups”:[“type”,“groupCharItem”]}

Trong Bui said:

could you paste me the whole ‘param’ value, I would like to debug it.

Can you please share if any update on this.

Abhijit,

I do appology for missing this case. I have investigated the script and it might not the issue of GlobalVariable usage. Your script is correct. I have adjust it a little bit to make it clear and print out the value.

RequestObject reqObj = findTestObject(‘API - Draft/UNLOCK GET ORDERS’)

reqObj.setRestUrl(GlobalVariable.restURL)

List params = new ArrayList<>();

params.add(new TestObjectProperty(‘searchString’, ConditionType.EQUALS, GlobalVariable.param))

params.add(new TestObjectProperty(‘fields’, ConditionType.EQUALS, GlobalVariable.param))

reqObj.setRestParameters(params)

for (param in reqObj.getRestParameters()) {

println param.getValue()

}

The topic is closed due to inactiveness. Feel free to open a new one if you have any concerns.

Hi

I tried this code of your and for some reason it doesn’t work on getting the url and setting of params.