jsreesoap
12 years agoContributor
How dinamically insert a filed in Rest-Jason request
Hi
I have a script that I am trying to run in iterations, in each iteration I am changing a value. Based on the value I need to dynamically add a field and value. For example 'offerMinumum =100' - this is not in original json script but I need to add it when the iteration is 3. I tried the following as a test:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def project = context.testCase.testSuite.project
def testSuite = project.getTestSuiteAt(5)
log.info(testSuite.getLabel())
def testCase = testSuite.getTestCaseAt(0)
log.info(testCase.getLabel())
def testStep = testCase.getTestStepAt(0)
log.info(testStep.getLabel())
def teststepname = testCase.getTestStepAt(4).getName().toString()
def inputHolder = +teststepname + "#Request"
log.info(inputHolder);
def holderRawReq = groovyUtils.getXmlHolder(inputHolder)
holderRawReq["//item:'offerMinumum"] = "100"
I picked this up from 'http://stackoverflow.com/questions/17522814/dynamically-setting-input-in-soapui-requests-with-groovy' but it throws 'groovy.lang.MissingMethodException: No signature of method: java.lang.String.positive() is applicable for argument types: () values: [] Possible solutions: notify(), size(), tokenize(), size(), tokenize() error at line: 13' error.
Any help pls?
Thanks in advance
I have a script that I am trying to run in iterations, in each iteration I am changing a value. Based on the value I need to dynamically add a field and value. For example 'offerMinumum =100' - this is not in original json script but I need to add it when the iteration is 3. I tried the following as a test:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def project = context.testCase.testSuite.project
def testSuite = project.getTestSuiteAt(5)
log.info(testSuite.getLabel())
def testCase = testSuite.getTestCaseAt(0)
log.info(testCase.getLabel())
def testStep = testCase.getTestStepAt(0)
log.info(testStep.getLabel())
def teststepname = testCase.getTestStepAt(4).getName().toString()
def inputHolder = +teststepname + "#Request"
log.info(inputHolder);
def holderRawReq = groovyUtils.getXmlHolder(inputHolder)
holderRawReq["//item:'offerMinumum"] = "100"
I picked this up from 'http://stackoverflow.com/questions/17522814/dynamically-setting-input-in-soapui-requests-with-groovy' but it throws 'groovy.lang.MissingMethodException: No signature of method: java.lang.String.positive() is applicable for argument types: () values: [] Possible solutions: notify(), size(), tokenize(), size(), tokenize() error at line: 13' error.
Any help pls?
Thanks in advance