Forum Discussion

abc123's avatar
abc123
New Contributor
9 years ago
Solved

use get as a template for post in RESTful server

Hello all, I'm new to SOUPUI, and I'm using the free version of SOUPUI. I’m trying to write some test cases. I spent all morning looking for this and I can't believe this has never been asked.  I'm...
  • rupert_anderson's avatar
    rupert_anderson
    9 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"].setPropertyValue("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