kiranRam
4 years agoOccasional Contributor
Passing custom parameter in Key of Query Param's key, value pair
Does SOAP UI allow passing Custom parameter value in Key of Query Parameter's Key, Value Pair? For Example: Query Parameter in my API is "product_12345"="1". The value 12345 is coming from previous ...
- 4 years ago
Hi,
Thank you a bit clearer now and yes, I think there is a way to achieve what you want.
This example is based on an API I have previously tested. The approach was call a GET service which returned a transaction number. Once you got this transaction number, you called it again with the payload and tagged the transaction number on the end. To achieve this, I used Groovy script in between the two calls.
You can actually overwrite the endpoint for a given test-step...
testRunner.testCase.testSteps["Some Test Step"].properties['Endpoint'].value = "https://some-url"
I guess in your Groovy script, it could be
testRunner.testCase.testSteps["Some Test Step"].properties['Endpoint'].value = "https://some-url"
something like....
// Define root url. Should actually get this from the Evironment dsata, but this is just for an example. def rootUrl = "http://myapi.com/apiname"; // Get the 12345 bit from the prevous test step def productCode = context.expand( '${Get Prod Code - REST Request#Response#$[\'message\'][\'error\'][0][\'row1\'][0]}' ) // Join the prefix to the product code def myParam = "product_" + productCode; log.info(myParam); // should be "product_12345" // Mixing single and double quotes as you'll want quoted elements in the URL def newEndpoint = rootUrl + '?"' + myParam + '":"xyx"'; // Update the endpoint for the test step. testRunner.testCase.testSteps["Some Test Step"].properties['Endpoint'].value = newEndpoint // NO NEED TO RETURN ANYTHING HERE