Forum Discussion
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.
- groovyguy6 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.");
- groovyguy6 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.
- subhaD6 years agoContributor
the reportdownloadUrls[99999999] is the value am trying to extract.
but 99999999 is from 1st request response am trying to take it in variable and pass it to this value, but not sure how to pass it ??
def URL = context.expand( '${2nd call#Response#$[\'data\'][\'resource\'][\'reportDownloadUrls\'][\'999999999\']}' )
I wanna parametrize the 999999999 part
- subhaD6 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\']}' )
Related Content
- 4 years ago
Recent Discussions
- 13 minutes ago
- 16 days ago