Ask a Question

how to add query parameter values into a REST resource path through Groovy

ssin48
Occasional Contributor

how to add query parameter values into a REST resource path through Groovy

how to add query parameter values into a REST resource path through Groovy

 

1. Is the below code correct to follow?

 

import com.eviware.soapui.support.types.StringToStringMap

def headers = new StringToStringMap()

headers.put("include", "value")
testRunner.testCase.getTestStepByName("REST Request").getHttpRequest().setRequestHeaders(headers)

 

 

2. Will this apend my resource path to include Query paramtere and is shown as below:

http://10.210.12.122:8080/mjo?include=value

SS
4 REPLIES 4
nmrao
Community Hero

What happens when you try?


Regards,
Rao.
ssin48
Occasional Contributor

This results in addition of a new header value - include.

SS
nmrao
Community Hero

You mean duplicate header gets added each time?


Regards,
Rao.
Nastya_Khovrina
SmartBear Alumni (Retired)

Hi Sandeep,

 

If I understand you right:

1. No, this code can be used to add headers to a request: https://www.screencast.com/t/kK5M8IwRM
2. To add query parameters to a request you can use the RequestFilter.filterRequest event and the following code:

 

 

// get method so we can get the complete URI
def method = context.getProperty( "httpMethod" )

//log.info( method.URI.toString() )

method.URI = new URI("http://10.210.12.122:8080/mjo?include=value?input=value")

context.setProperty( "httpMethod", method )

//log.info( method.URI.toString() )

 


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: