- Set the baseURI property of the RESTASSURED static class
Example:
RestAssured.baseURI = "http://restapi.demoqa.com/utilities/weather/city"; - Create the RequestSpecification object and assign it with RestAssured.Given() method.
Example:
RequestSpecification httpRequest = ResetAssured.Given(); - Create the Response object and assign it with requestSpecificationObject.request() method
Example:
Response response = httpRequest.Request(METHOD.GET, "/Hyderabad");
Note: "/Hyderabad" is the parameter passed in GET request - The Response of the request invoked can be accessed using the response object
Example:
System.out.println(response.getResponseBody());
Notes:
JSONObject requestPayload = new JSONObject();
requestPayload.put("FirstName", firstName);
requestPayload.put("LastName", lastName);
requestPayload.put("UserName", userName);
requestPayload.put("Password", password);
requestPayload.put("Email", emailId);
httpRequest.header("Content-Type", "application/json");
httpRequest.body(requestPayload.toJSONString());