Forum Discussion
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}????
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
ChrisAdams I was able to resolve the issue with the script provided. Thanks for the help.