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.
Personally, and just my preference, I tend not to use custom properties. I prefer 'pulling' the value of interest from a previous step into the current step. This can be done in a similar to what you're trying, but maybe not exactly. If you just wanted the 12345 value, then yep. But it looks like you want the value concatenated with a word. In these cases, I would add a Groovy script step in between the step returning 12345 and the step you want to pull it into.
This Groovy step would be used as a stringbuilder for the 'current' step.
E.g. this Groovy step in-between your two steps. Just for example name the Groovy script step "getProductParam"...
// 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"
return myParam;
Then in the next test step, 'pull' the value into the query params part by typing....
ChrisAdams Thanks for the response. My apologies if question was ambiguous. If I understand it correct, you're passing the Param value as a 'Value' in the request, while I want it to be passed as a Key.
In your Last Screenshot, key is 'data' and Value is '{getProductParam#result}'. I want Key as {getProductParam#result}, since the value '12345' keeps changing in my API. If I send Query Param as "{getProductParam#result}":"XYZ", SOAP UI is not recognizing the parameter, understandably. Is there a way I can send Key as Product_12345 by making it as a custom Param: {getProductParam#result}????
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