I have created an api test which hits an endpoint and receives a response back however I'm struggling to use this response within another cucumber step.
My first step uses the following method:
public Response booking(SharedStepData sharedStepData, String path, BookingType bookingType) throws IOException {
String url = "https://example.net." + System.getProperty("endpoint") + "/v10/" + path + "Booking";
RestAssured.useRelaxedHTTPSValidation();
String payload = createBookingPayload(sharedStepData, bookingType);
Response response = RestAssured
.given().contentType(ContentType.JSON)
.log().all()
.body(payload)
.when().post(url)
.thenReturn();
ResponseBody body = response.getBody();;
return response;
}
I know need to save this response and then use it within another step method to perform another action, such as using specific data from the response to hit another endpoint, any ideas?