rest-assured-jsonpath

The import io.restassured.RestAssured cannot be resolved

筅森魡賤 提交于 2021-01-27 14:42:11
问题 Hi I am not able to resolve the error while using rest assured 4.1.1. library in my Eclipse IDE. I have added the rest assured library in my pom.xml file still the error is not resolved. I tried re-importing the rest assured library from https://mvnrepository.com/artifact/io.rest-assured/rest-assured/4.1.1 But still doesn't work <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http:/

“Application/vnd.api+json” throws “Unsupported Media Type”

社会主义新天地 提交于 2020-07-22 05:47:59
问题 I am automating an API for a POST call using Rest Assured and for Content-Type and ACCEPT header I have to use " application/vnd.api+json ". But every time I use "application/vnd.api+json" I get 415 status code. Although the same POST call using Postman works perfectly fine. Here is my sample code : ApiUtils.setBaseURI("xxxxx"); ApiUtils.setBasePath("/orders"); RequestSpecification request = RestAssured.given().auth().oauth2(BaseClass.token); request.header("ACCEPT", "application/vnd.api+json

“Application/vnd.api+json” throws “Unsupported Media Type”

烂漫一生 提交于 2020-07-22 05:47:06
问题 I am automating an API for a POST call using Rest Assured and for Content-Type and ACCEPT header I have to use " application/vnd.api+json ". But every time I use "application/vnd.api+json" I get 415 status code. Although the same POST call using Postman works perfectly fine. Here is my sample code : ApiUtils.setBaseURI("xxxxx"); ApiUtils.setBasePath("/orders"); RequestSpecification request = RestAssured.given().auth().oauth2(BaseClass.token); request.header("ACCEPT", "application/vnd.api+json

RestAssured Parsing Json Array Response using foreach loop

ぃ、小莉子 提交于 2020-07-09 19:16:25
问题 I have response from RestAssured which is a JsonArray looks similar to the below code [{ "id": "1", "applicationId": "ABC" }, { "id": "2", "applicationId": "CDE" }, { "id": "3", "applicationId": "XYZ" }] I use code to get the "id" from the first Json element List<String> jresponse = response.jsonPath().getList("$"); for (int i = 0; i < jsonResponse.size(); i++) { String id = response.jsonPath().getString("id[" + i + "]"); if(id.equals("1"){ do something } else { something else } } Is there a

RestAssured Parsing Json Array Response using foreach loop

十年热恋 提交于 2020-07-09 19:15:08
问题 I have response from RestAssured which is a JsonArray looks similar to the below code [{ "id": "1", "applicationId": "ABC" }, { "id": "2", "applicationId": "CDE" }, { "id": "3", "applicationId": "XYZ" }] I use code to get the "id" from the first Json element List<String> jresponse = response.jsonPath().getList("$"); for (int i = 0; i < jsonResponse.size(); i++) { String id = response.jsonPath().getString("id[" + i + "]"); if(id.equals("1"){ do something } else { something else } } Is there a

java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to pojo.class

丶灬走出姿态 提交于 2020-06-17 15:50:19
问题 Getting java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to pojo.class while serializing Generic type.Kindly assist. This is the code written for Json fileReader class. public class ReadJsonFile<T> { private static final Object ReadJsonFile = null; public static void main (String[] args) { ReadJsonFile read = new ReadJsonFile(); read.getjsondata("src/test/resource/testdataresource/addplacerequest.json", Addbook.class); } public List<T> getjsondata(String

I am unable to post an Add Place API when using POST http method

喜欢而已 提交于 2020-06-17 09:10:48
问题 io.restassured.path.json.exception.JsonPathException: Failed to parse the JSON document It is throwing error in the code written for these Feature file steps: Given Add new location with "<name>" "<language>" "<address>" parameters Then user calls "AddPlaceAPI" with http "POST" method Then API successful response with "status" as "OK" The stepDefinition code for these steps @Given("Add new location with {string} {string} {string} parameters") public void Add_new_location_with_three_parameters

I am unable to post an Add Place API when using POST http method

送分小仙女□ 提交于 2020-06-17 09:10:07
问题 io.restassured.path.json.exception.JsonPathException: Failed to parse the JSON document It is throwing error in the code written for these Feature file steps: Given Add new location with "<name>" "<language>" "<address>" parameters Then user calls "AddPlaceAPI" with http "POST" method Then API successful response with "status" as "OK" The stepDefinition code for these steps @Given("Add new location with {string} {string} {string} parameters") public void Add_new_location_with_three_parameters

Building a nested JSONObject

大城市里の小女人 提交于 2020-06-17 07:24:06
问题 Below is the code I am using JSONObject requestParams = new JSONObject(); requestParams.put("something", "something value"); requestParams.put("another.child", "child value"); This is how the API needs to be posted { "something":"something value", "another": { "child": "child value" } } I get an error stating that "The another.child field is required." How do I go about posting this via restAssured? The other APIs that do not require posting with nesting work, so I'm assuming that's why it's