Forum Discussion

richie's avatar
richie
Community Hero
6 years ago

Asserting on contents of a .json response in output log & passing attribute values to propertiesstep

Hi,   nmrao put a script together for me to build a GET REST request's URI and query string using groovy (I cant use the OTB functionality due to other project requirements) and the GET request's...
  • NBorovykh's avatar
    6 years ago

    Hi richie,

     

    I've modified your code in the following way:

    import groovy.json.*
    
    def response = context.expand( '${REST Request#Response}' )
    def object = new JsonSlurper().parseText(response)
    
    assert object.header.success == true
    assert object.data[0].Links.method == "GET"
    assert object.data[0].VersionNumber == 1

     

    It works fine for me: