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 step's response, so I am storing it as a Customer Param and trying to send the key as "product_${#TestCase#productNumber}" but SOAP UI is unable to recognize it. Is there a way to do it? Thanks in advance.
Note: I can't the send the query parameter in a JSON body, it has to go a Form/URL encoded value.
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