If you use the net.serenitybdd.cucumber.CucumberWithSerenity Runner:
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(...)
then you can use this helper method:
import net.thucydides.core.steps.ExecutedStepDescription;
import net.thucydides.core.steps.StepEventBus;
import org.apache.commons.lang3.StringUtils;
public static void showMessage(final String message) {
String escapedMessage = message;
escapedMessage = StringUtils.replace(escapedMessage, "|", "|");
escapedMessage = StringUtils.replace(escapedMessage, " ", " ");
escapedMessage = StringUtils.replace(escapedMessage, "_", "_");
StepEventBus.getEventBus().stepStarted(ExecutedStepDescription.withTitle(escapedMessage));
StepEventBus.getEventBus().stepFinished();
}
This will print any message on the Serenity-Report of the current Step-Execution
For your special case you can use serenity-rest-assured
SerenityRest.given()
.contentType("application/json")
.header("Content-Type", "application/json")
.body("{...}")
.when().post("/...")
.getStatusCode();
It generates a button into the serenity report where all details of the Requests are shown.
See the last Screenshot on the Article:
https://www.blazemeter.com/blog/restful-api-testing-using-serenity-and-rest-assured-a-guide/