I have added below dependencies in my POM.xml file to automate API with RestAssured- rest-assured, json-path, json-schema-validator, xml-path and jackson-databind. But I am not getting response for the same. However, it's working fine in Postman. Below id my code-
package FirstAPIProject.firstAPIProject;
import static io.restassured.RestAssured.*;
import io.restassured.RestAssured;
public class Sample {
public static void main(String[] args) {
// TODO Auto-generated method stub
RestAssured.baseURI="https://rahulshettyacademy.com";
String response=given().queryParam("key", "qaclick123").headers("Content-Type", "application/json")
.body("{\r\n" +
" \"location\": {\r\n" +
" \"lat\": -38.383494,\r\n" +
" \"lng\": 33.427362\r\n" +
" },\r\n" +
" \"accuracy\": 50,\r\n" +
" \"name\": \"Rahul Shetty Academy3\",\r\n" +
" \"phone_number\": \"(+91) 983 893 3937\",\r\n" +
" \"address\": \"29, side layout, cohen 09\",\r\n" +
" \"types\": [\r\n" +
" \"shoe park\",\r\n" +
" \"shop\"\r\n" +
" ],\r\n" +
" \"website\": \"http://rahulshettyacademy.com\",\r\n" +
" \"language\": \"French-IN\"\r\n" +
"}")
.when().post("maps/api/place/add/json").then().assertThat().statusCode(200).toString();
System.out.println(response);
}
}
Output-
io.restassured.internal.ValidatableResponseImpl@4bd1f8dd
Aucun commentaire:
Enregistrer un commentaire