Forum Discussion

AAB's avatar
AAB
Regular Contributor
4 years ago
Solved

ReadyAPI get content of RAWResponse with groovyscript

Hello,   I need some developers who could help me here please. Here is what I'm expecting to happen:   Run Rest request and read the raw response to get an ID in it Raw response =      HTTP/...
  • HimanshuTayal's avatar
    4 years ago

    AAB :

     

    Sorry, i understand it incorrectly, you said raw response but as that ID is coming into 1 of the headers.

     

    You can use below updated groovy code to fetch ID:

     

    import groovy.json.JsonSlurper
    
    def jsonSlurper
    testRunner.testCase.getTestStepByName("Rest Request").testRequest.response.responseHeaders.each { 
    	if (it.key == "X-BOSA-ServiceInfo")
    		jsonSlurper = new JsonSlurper().parseText(it.value)
    }
    def applicationID =  jsonSlurper.ApplicationID
    assert applicationID != "" : "applicationID is blank"
    assert applicationID != null : "applicationID is null"
    testRunner.testCase.setPropertyValue("id",applicationID.toString())

     

    For UI part you can refer below link:

     

    https://learnsoapui.wordpress.com/tag/groovy-script/