Post data using rest assured. Method 1

In order to create a new record in our app using post or in order to post to any rest app in general

There are few ways. 1.We used above. We created an external json file and the created a file object of that file and passed it post body.

  File jsonBody = new File("C:\\workspace\\RestAssuredProject\\students.json");        
  given().contentType(ContentType.JSON).body(jsonBody).post().then().log().headers();

And here is our students.json file. In this we see we have a jsonObject that has key value pairs and it also contains a list of objects which we call jsonArray.

{
        "firstName": "Harryabc",
        "lastName": "SiaajjhDh",
        "email": "HSingh@qdqsdsds.org",
        "programme": "Financial Analysis",
        "courses": [
            "Accounting",
            "Math",
            "Statistics"
        ]
    }