How can I save part of response into variable, and reuse it at the middle of next request line? (Java)

Hi, I have a scenario with two requests written in Java, I will simplify it in this message.

request 1 - post with some data, that getting a response with a link like { https://qwerty/**id143214** }

request 2 - post, in which I need to reuse id143214 from previous response, and put it at the middle of request 2 line: https://checkingif/**id143214**/isExist

I have tried to use check(bodyString().saveAs("idfromlink)) and then create a string in which I can use the substring method to get the id143214, but the string isn’t reusable in the next exec/request

I believe there is another way to correctly do what I’m trying :frowning:

you need to put that substring value into a session attribute, see here

fast code snip:

exec(session -> {
  Session newSession = session.set("variable_name", "id143214");
  return newSession;
});

Then to use it in request, use #{variable_name}

Hello,

Can you share with us your code?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.