I am using the API as a reusable same API is used to get values for different dates.Only date is getting changed so i have used Request Specification but when i try to run getting the error message as Specification to merge with cannot be nullError message
@BeforeEach
public static void SetupRequestSpecBuilder() {
reqBuilder = new RequestSpecBuilder();
reqBuilder.setContentType("application/json");
reqBuilder.addHeader("Content-Type", "application/json");
reqBuilder.addQueryParam("ap_type", apptype);
reqBuilder.addQueryParam("days", days);
reqBuilder.addQueryParam("room_id", roomid);
reqBuilder.addQueryParam("date_req", today.toString());
reqSpec = reqBuilder.build();
}
@Step("user perform a search for Current Day")
public void GETDairySearch() {
logger.info(("STEP: user perform a search"));
response = SerenityRest.given().spec(reqSpec)
.when()
.get(endpoint + basePath);
response.then().log().all().assertThat().statusCode(200);
logger.info(" Endpoint is: :: " + endpoint + basePath);
template_slot_id = response.jsonPath().getString("diary.template_slot_id[0]");
template_slot_id_new = response.jsonPath().getString("diary.template_slot_id[1]");
logger.info(" Slot_id_for_CurrentDay :: {}", template_slot_id);
logger.info(("STEP: user perform a GET diary search"));
}
}
Instead of calling the .spec(reqSpec) tried with .spec(SetupRequestSpecBuilder) it worked