How do I do a property transfer with multiple source responses into one target?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How do I do a property transfer with multiple source responses into one target?
I'm using the brand new SoapUI 5.2.1 which may be my first mistake but what I'm trying to do is transfer 2 values from my responce into one target. In order to authenticate I have to provide the token_type followed by the access_token with only a space in between in the header of my next REST call.
So my responce from the original call to get my access token looks like this:
{ "access_token": "5co25gnf7noh9u4ufjpn1j2dms", "token_type": "Bearer", "expires_in": 360, "refresh_token": null }
I know how to transfer either the token_type or the access_token by itself but I need them to go together, however, I can't figure out the syntax to get them to both go.
The closest I've gotten was to put them into an array but then of course it returns an array and I get a 401 status when I try to use it in the auth header. Everything else I've tried I get a JSON error. Anyone have any ideas?
P.S. is anyone else having trouble with 5.2.1 and snap in Win7? My window keeps flying all over the place!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes it's a header:
I simply need it to say Bearer accesstoken
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately, do not have environment to try that property transfer to get it work.
What i see is you will be able to access the values from first Json response
change from
[token_type, access_token]
to
add two properties in Property transfer step
prop1 -> $.token_type
prop2-> $.access_token
But the problem is each one goes to different target.
For now, the below solution should be helpful
Disable property transfer step.
Add the script assertion with following code for the first rest step
import net.sf.json.groovy.JsonSlurper def jsonSlurper = new JsonSlurper() def object = jsonSlurper.parseText(messageExchange.responseContent) def accessToken = object.access_token def tokenType = object.token_type assert null != accessToken, "access_token does not have a value" assert null != tokenType, "token_type does not have a value" def authorizationKey = "${tokenType} ${accessToken}" context.testCase.setProperty('AUTH_KEY',authorizationKey)
Now in the second step, use ${#TestCase#AUTH_KEY} where the value is required.
Regards,
Rao.
