java.lang.IllegalStateException: Target host is null is observed on executing | Rest Assured Forum
S
Sridhar Rao n Posted 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 Replied on 23/12/2019

Check if application is running.


S
Sridhar Rao n Replied on 24/12/2019

Yes, Application is Running


S
Sridhar Rao n Replied on 24/12/2019

Yes, Application is Running