Fibonacci JavaCode to replace data variable in request chain

• This is the request I post/send to the 1st endpoint using JSON body as Content as prescribed:

  1. {

“fullName”: “jason”,


3. ```
 "email": "jason@testing.com"
  1. }

• I then receive this response:

  1. {

“token”: “dTh7Pef1wPA8Ngvl-1Fjjk”,


3. ```
 "challenge": "FIBONACCI",

“data”: 75


5. }
• I created an Environment that then has the following variables
VARIABLE INITIAL VALUE CURRENT VALUE
token abc abc
data 123 123

• Within the 1st endpoint I have included a test script as follows so that I automatically
Transfer the data acquired in the first response to the 2nd endpoint and thus a Request response
Chain.
Test script in 1st endpoint:

1. bodyData = JSON.parse(responseBody)
2. value = bodyData.token
3. console.log(value)
4. pm.environment.set(“token”,value);
5. value2 = bodyData.data
6. console.log(value2)
7. pm.environment.set(“data”, value2);

• These variable are then collected and entered in the request(post/send) in the 2nd endpoint
Using JSON body as content as prescribed:

1. {
2. “token”: “{{token}}”,
3. “result”: “{{data}}”
4. }
• Thus far it is doing exactly what I need which is to send the first request to the 1st endpoint url
then receive a response with the token key and data to be used for calculation. The issue is that
the new data variable has to be calculated and the output replacing the data variable stored so that it could be used in the second request in the 2nd endpoint.
Please assist in using the following code:
5. //Fibonacci Series using Recursion
6. class fibonacci
7. {
8. static int fib(int n)
9. {
10. if (n <= 1)
a. return n;
11. return fib(n-1) + fib(n-2);
12. }
13. public static void main (String args)
14. {
15. int n = 9;
16. System.out.println(fib(n));
17. }
18. }
NOTE THE TOKEN ONLY LASTS FOR 5 SECONDS HENCE WHY I NEED EVERYTHING TO HAMPPENT SWIFTLY AND QUIC

@Bhekz answered in your other post. request more clarification on what you would like to achieve with a clear code.