Forum Discussion
The part of URL in the second call response is based on the value sent in first call
So am trying to parametrize the value for URL using the value from first call
I think it would be cleaner to use an Property Transfer test step to extract a property and then just use it in the second call.
- TanyaYatskovska7 years ago
Alumni
- groovyguy7 years agoCommunity Hero
You can try something like what I've posted below. If it doesn't work, can you provide your response for the two calls so I can navigate the response with groovy and parse it out better? Even if it's a sample mocked up response.
def aaa = context.expand( '${1st Call#Response#$[\'data\'][\'res\'][\'b\'][0][\'aaa\']}' ) def response = context.expand( '${2nd call#Response#$[\'data\'][\'res\'][\'reportDownloadUrls\'][\'$aaa\']}' )Typically when working with strings, you can use $ and a variable name to make the string's contents respect it as a variable. So the two are the same below:
log.info ("Hello world, my name is Matthew."); def name = "Matthew"; log.info("Hello world, my name is $name.");- groovyguy7 years agoCommunity Hero
Looking at this, it's not as simple as I thought it was. Still, to be a better help, can you provide sample or mocked up response that I can parse with groovy? That would help me a log, as I am unfamiliar with the syntax you are using in the content.expand statement.
- subhaD7 years agoContributor
I have a first request that has the value 999999999 in a request tag
In my second request i have below value.
"reportDownloadUrls" : {
"999999999" : "/credit-report-download/1854/df0d2929"
}To be able to parametrize 999999999 value i have below groovy.. and got stuck there, trying to pass variable instead of the number sicne the number can change
def URL = context.expand( '${2nd call#Response#$[\'data\'][\'resource\'][\'reportDownloadUrls\'][\'999999999\']}' )