cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
Frequent Contributor

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

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

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

Hi @AboveAndBeyond,

 

Take a look at the examples here:

https://smartbear-cc.force.com/portal/KbArticleViewer?name=How-to-change-a-parameter-value-for-all-R...

https://smartbear-cc.force.com/portal/KbArticleViewer?name=How-can-I-change-default-request-properti...

https://community.smartbear.com/t5/SoapUI-Pro/how-to-transfer-property-from-post-response-to-a-json-...

 

I think they will give you some clue.

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

2 REPLIES 2
Super Contributor

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

@AboveAndBeyond 

 

The response which contains beID is a JSON then you can again use JSONSLURPER if not then you can write some logic like use split or replace then split, so that you will be able to get the desired id.

 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" Smiley Happy

Thanks and Regards,
Himanshu Tayal
Community Manager

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

Hi @AboveAndBeyond,

 

Take a look at the examples here:

https://smartbear-cc.force.com/portal/KbArticleViewer?name=How-to-change-a-parameter-value-for-all-R...

https://smartbear-cc.force.com/portal/KbArticleViewer?name=How-can-I-change-default-request-properti...

https://community.smartbear.com/t5/SoapUI-Pro/how-to-transfer-property-from-post-response-to-a-json-...

 

I think they will give you some clue.

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

New Here?
Join us and watch the welcome video:
Top Kudoed Authors