I want to use partitial value in my request from a earlier response. I can use tranfer property or use get data but then I get the whole value and not a part what I need in my request.
As example: In a earlier response I have value 00123456789 in a property "id"
Now I want to use the first 8 digits in my next request. That's 00123456
How can I use a part of the value in my request?
Solved! Go to Solution.
@jsontester : You can use below code sample, it is the implementation what @richie has suggested you
import groovy.json.JsonSlurper
def response = testRunner.testCase.getTestStepByName("TEST__STEP__NAME").getPropertyValue("Response")
slurperRes = new JsonSlurper().parseText(response)
def val = slurperRes.PATH__TO__VALUE
def desired_Val = val.take(8)
log.info desired_Val
Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓
Hi,
@richie is right here. Though, one suggestion would be to do away with the property transfer, it's not required.
Personally, I'd stick a groovy step in between the two test calls. The Groovy step would be invoked by the second step. The groovy can read the value from the first call, manipulate and return the manipulated value directly into the payload of the second test call.
@jsontester : You can use below code sample, it is the implementation what @richie has suggested you
import groovy.json.JsonSlurper
def response = testRunner.testCase.getTestStepByName("TEST__STEP__NAME").getPropertyValue("Response")
slurperRes = new JsonSlurper().parseText(response)
def val = slurperRes.PATH__TO__VALUE
def desired_Val = val.take(8)
log.info desired_Val
Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓
thanks for the solution. I'll click "Accept as Solution" if it works. I can't identify the correct paths when I select GET data from a rawrequest now.
@jsontester : If it is allowed please post your json here or DM me i will be happy to help 🙂
Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓
Subject | Author | Latest Post |
---|---|---|