How pull property value to the next json body request using proprty transfer?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How pull property value to the next json body request using proprty transfer?
Hey hey, lovely community! I need your lovely little support 😄
I am testing API on one project. So, and faced with a question:
How pull property value which was taken in response to the next property in JSON body request using proprty transfer?
What I have
1. I have a request to a server from where I get a property in JSON body response which I want to move as value to the next
body request. Here is screenshot: http://joxi.ru/KAgGBgeH4Ebx7A
And
Question number 2 is how to take this value http://joxi.ru/D2PQdzJHpqzoeA from a header and pull into the header parameter "cookie" in next request?
Please, need your little support, ladies and gents!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. Add a property transfer test step then select the required source test step, source property = Response, source language = JSONPath, and selection from source property = $.sms_code. You can then use the target property in the next request with Property Expansion
2. Try a Groovy script to Pass cookie value to another request
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not much familiar with Json Path along with Property Transfer. I would prefer to do it using Script Assertion for the first request test step.
The following Script Assertion would fetch the required value and set the value test case level custom property and access the value using property expansion in the following test steps.
assert context.response, "Response is empty of null" def parsedJson = new groovy.json.JsonSlurper().parseText(context.response) log.info "Retrieved sms code : ${parsedJson.sms_code}" assert parsedJson.sms_code, "sms code is null or empty in the response" context.testCase.setPropertyValue('SMS_CODE', parsedJson.sms_code.toString())
In the following request, use ${#TestCase#SMS_CODE} where you needed that value.
And regarding your 2nd question, please refer the below script which is done some time for similar requirement.
https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/AddCookiesToNextRequest.groovy
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've tried your way and it doesn't work. I think that I specified it in an incorrect place.
Could you please clarify this moment?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can we have a fast skype call?:) Because it doesn't work for me still doesn't work. http://joxi.ru/823pvd6fJ91M3A - is it correct?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've got the problem. Thanks. Now it works.
And what can be the reason of this behavior? Why "phone" property is not moved to request? - http://joxi.ru/VrwlzEXuO7NZLm
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Titanium22
At first glance, you need to specify the JSONpath expression to use the phone data from a previous request message
${Teacher_Create#Request#$.phone}
or
${Teacher_Create#Request#$['phone']}
