Groovy script - Sum two values of REST response and pass the sum on to the next request
Hi!
I'm currently utilizing ReadyAPI for functional tests of our API.
I am already using "simple" property transfer / Get Data to pass on a value from one test step REST response to the next REST request like:
${TestStep1#Response#$['ABC']['Array'][0]['Price']['value']}
Now what I want to achieve is passing on the sum of two values of a response to the next request.
E.g. let's say Test Step 1 Response gives me the following data:
Now I want to pass on the sum of the prices (1.4 + 2 = 3.4) to a field of the next request.
I was told by Smartbear Support that this can be achieved using Groovy scripts but they do not offer customer support for scripts and I was referred to this Community form.
As I am totally new to Groovy Script and not sure about how to use it for my goal which isn't complex at all but again, I have never used Groovy Script before, I am asking if someone could help of an example of how this would look like?
Maybe also with an example if the values were returned in string format and I would need to parse them to Double first?
Thank you!