use get as a template for post in RESTful server
- 10 years ago
Hi,
As simple as you expected? I thought you were surprised that it wasn't simpler to do in your first post! I am happy you are happy anyway! :-)
I notice you used JSONPath rather than JSON Slurper, which is fair enough, but I would say that JSON Slurper is a little neater e.g. no need to import and a little nicer syntax - would make the solution something like:
import groovy.json.JsonSlurper
def response = context.expand('${GetRecord#Response}')
slurper = new JsonSlurper().parseText(response)
slurper.name = 'abc123'
testRunner.testCase.testSteps["UpdateRecord"].setPropertyValue("Request", slurper)
(I have tested this now, whereas before I was guessing :-) )
Also instead of setting a context property, you have now decided to update the TestStep request property directly:
testRunner.testCase.testSteps["UpdateRecord"].setP
ropertyValue("Request", jsonString) quite nice though!
If you're happy to please can you mark the topic as solved so that others might benefit?
Thanks for sharing your solution back,
Cheers,
Rup