Forum Discussion
- mgroen2Super Contributor
No one?
- nmraoChampion Level 3Looks this is related to this other thread of yours. Have you tried with script provided there?
You haven't mentioned where you need to use the extracted value, by the way?
https://community.smartbear.com/t5/SoapUI-Open-Source/How-to-assert-on-value-in-a-Json-response/m-p/139172#U139172
It is even not sure what happened to other question as it is still open while many relevant answers were provided. If you found helpful answer or solved altogether please convey that. No response to the solutions provided to your earlier questions.
Regarding this question: you need to add another statement to script provided in the above thread.
context.testCase.setPropertyValue('TOKEN', parsedJson.accessToken.toString())
In order to access the TOKEN in other request steps, use property expansion ie., ${#TestCase#TOKEN}
- simonjdonnellyContributor
Does the accessToken value need to be entered as part of the request XML or as one of the soapui properties?
If it needs to be part of the XML, are you not able to pass a tokenised value through i.e.
<Test>${Login 1 - Portal Login#Request#//accessToken[1]}</Test>
For example purposes:
My Login 1 - Portal Login request looks like this:
<accessToken>1234</accessToken>
so the Test element should be replaced with 1234 upon executing the second request.
- mgroen2Super Contributor
simonjdonnelly wrote:Does the accessToken value need to be entered as part of the request XML or as one of the soapui properties?
If it needs to be part of the XML, are you not able to pass a tokenised value through i.e.
<Test>${Login 1 - Portal Login#Request#//accessToken[1]}</Test>
For example purposes:
My Login 1 - Portal Login request looks like this:
<accessToken>1234</accessToken>
so the Test element should be replaced with 1234 upon executing the second request.
simonjdonnellythe responseof the first request is this:
I need to have the value for accesstoken be pasted in subsequent requests. But I can't do it using Property Transfer.
- simonjdonnellyContributor
Passing the value through as a parameterised version should work then:
I don't have any sample REST JSON services to hand, so I've used soap but it shouldn't be too different:
Place ${Login 1 - Portal Login#Request#//Response[1]/accessToken[1]} in the second request, where you want the access token previously generated to appear.
This will take the value from the test step named 'Login 1 - Portal Login' and take the accessToken from the structure Response > accessToken.
Related Content
Recent Discussions
- 15 years ago