Forum Discussion

AAB's avatar
AAB
Regular Contributor
6 years ago

How to put a parameter from a JSON URL response in a REST Request

Hello,

 

For my project I need to read a JSON response through a URL. I've managed to do so, but now I should put a particular property into the REST Request. How can I do this please?

So far:

//cfr.  https://www.leveluplunch.com/groovy/examples/get-webpage-content-url-uri/
//https://community.smartbear.com/t5/SoapUI-Pro/How-to-Parse-a-JSON-Response-Using-Groovy-Examples/td-p/155770
import groovy.json.JsonSlurper

def getConceptSchemes = "https://LinkToMyEnvironment".toURL().getText()
//parse json string using JsonSlurper - basically converts it to a groovy list
def parsedJson = new groovy.json.JsonSlurper().parseText(getConceptSchemes)
//get data
def findAGC = parsedJson.find { it.name == 'ACTIVITY_GROUP' }
log.info "result for specific beID: " + findAGC

This gives me the answer from the Json response.

This is a first step in my TestCase.

The second step is a REST Request with parameter 'beId' that I need to fetch from the response.

Response:

{"beId":"d4f897d05508caa12d77d732ffbc652f821c0a16c2f457277c2565f0b890f62e","name":"ACTIVITY_GROUP","reportingAuthority":"KBO","links":[{"rel":"self","href":"http://LinktomyEnvironment/d4f897d05508caa12d77d732ffbc652f821c0a16c2f457277c2565f0b890f62e{?lang}"}]},

How can I do so please?

 

Thanks in advance

AAB