RestAssured.basePath="http://localhost";
RestAssured.baseURI="/student";
RestAssured.port=8080;
JSONObject obj=new JSONObject();
obj.put("firstName", "Sridhar");
obj.put("lastName", "Navathe");
obj.put("email", "sridharrao.navathe@yahoo.com");
obj.put("programme", "CS");
JSONArray arr=new JSONArray();
arr.put("C");
arr.put("C++");
arr.put("Java");
obj.put("courses", arr);
// "java.lang.IllegalStateException: Target host is null" Error is coming on executing
Response re=given().contentType(ContentType.JSON).log().body().body(obj.toString()).post();
re.prettyPrint();
OutPut of this program: java.lang.IllegalStateException: Target host is null
on executing this program: it will post student record to database. it should print "Student added"
Check if application is running.
Yes, Application is Running
Yes, Application is Running