Search code examples
rest-assuredserenity-bddrest-assured-jsonpathcucumber-serenity

How to fetch and display the POST Request Body Content in Rest Assured with Junit - Serenity Report


I am using Serenity BDD framework with Rest assured Junit5. While creating the post request using using 'mvn clean install' command in index file report , I am unable to see the request body. its displaying the path which I provided for the json file. but not the actual POST request body content.

Can someone please advise on how to display the POST Request Body Content in the index file Report. enter image description here


Solution

  • Step 1: Convert json file to String.

    String payload = new String(Files.readAllBytes(Paths.get("path_to_file")));
    

    Step 2: Put it in request body

    given().contentType(ContentType.JSON).body(payload)...