java.lang.IllegalStateException: Target host is null is observed on executing | Rest Assured Forum

java.lang.IllegalStateException: Target host is null is observed on executing

S
Sridhar Rao n Post on 23/12/2019

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"

 

 

 

M
Maheshwari Mallikarjun Swami Reply on 23/12/2019

Check if application is running.

S
Sridhar Rao n Reply on 24/12/2019

Yes, Application is Running

S
Sridhar Rao n Reply on 24/12/2019

Yes, Application is Running