Questions tagged [rest-assured-jsonpath]

For use only with the popular REST-Assured API testing framework for Java.

Path-based query syntax for JSON documents in the REST-Assured framework for API testing. Not to be confused with the JsonPath specification (http://goessner.net/articles/JsonPath/)

Docs: https://github.com/rest-assured/rest-assured/wiki/Usage#json-using-jsonpath

382 questions
1
vote
2 answers

How to assert list of string is in sorted order using testng in java?

I am fetching response in sorted order from Get call using "http am.com/au/v/so?sort=name". It fetches the results in sorted order. How can I assert the the name in the list is in alphabetical order. List list = new ArrayList(); …
selvi
  • 1,271
  • 2
  • 21
  • 41
1
vote
1 answer

Validate json schema of a particular JSON object from a response

I have a json response like this(Response is getting in the com.jayway.restassured.response.Response format). [{ gameIdGlobal: 1947634, season: 2017, views: [{ name: "Recap", displayOrder: 1, …
Psl
  • 3,830
  • 16
  • 46
  • 84
1
vote
2 answers

Building a nested JSONObject

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 { …
1
vote
1 answer

How to find key from value in rest assured java?

I am using rest assured java and i am using post request in order to get the response. From my code i am able to get the response and i am seeing that in response i am seeing that value which i want to store is present in the keyset. Here is the…
1
vote
0 answers

JSONPath : preserving contents at filtered values

Below is the JSON content on which I was trying to extract the contents of matched filters { "results": [{ "individualProviderId": "P1", "locations": [{ "addressInfo": { …
Syed Rafi
  • 825
  • 2
  • 12
  • 35
1
vote
1 answer

How to pass content type "application/x-www-form-urlencoded" with rest assured

I am trying to hit API using Rest assured which is a POST request with form param client id, user and password. and multiple header . I am getting 415, unsupportted media type error. My code is: Response res = given(). .header("Accept",…
itin
  • 430
  • 3
  • 9
  • 20
1
vote
3 answers

Not able to fetch Json object from restassured Response(in json)

I am getting response from the server in json format by hitting post request using restAssured using java. Response response = requestSpecification.body(text).post(endpoint); now i want to fetch sub json object named "freebies". How can i perform…
rajan
  • 77
  • 1
  • 7
1
vote
1 answer

Parsing JSONArray when no key is present using restassured

i am using restassured to test my rest APIs and I have a scenario where my rest API returns a JSONArray without any key value like below. While browsing through multiple questions i havent seen similar JSONArray handled without key value. Verifying…
1
vote
1 answer

Inserting particular Json Key value in a Json body pulled from Oracle DB

Lets say i have a sample Json Request Body stored in an Oracle DB which i'll be using it multiple times in Java code(Doing POST method using RestAssured) Sample json Req. Ex: xxxRequest{ yyyDetails{ "accountId": "????", …
1
vote
1 answer

matchesJsonSchemaInClasspath in not working even if the input and output is fairly different

I have been trying to use the matchesJsonSchemaInClasspath method for verifying my API against a predefined JSON, but even if I JSON format, the test case keeps on getting passed, not sure what am I doing wrong here. Or is it the limitation for…
1
vote
2 answers

RestAssured response validation using body and array as parameter

I am trying to validate a REST response. Is it possible to use an array as parameter to containsonly? Ex: String values[] = line.split(","); given(). when(). then(). statusCode(200). …
Nix
  • 41
  • 3
1
vote
1 answer

Matching the Json schema with the response getting from the API in rest-assured

I have a post API , i want methods of JsonSchemaValidator to be used as I want the whole reponse to be validated rather than selected reponse by performing assertion I have tried to use matchesJsonSchemaInClasspath("my file name") and…
1
vote
1 answer

Escape dots in Groovy GPath

I am using the RestAssured framework in Java, whose documentation contains this note Note that the "json path" syntax uses Groovy's GPath notation and is not to be confused with Jayway's JsonPath syntax. I need to validate the following…
Vlad.Bachurin
  • 1,340
  • 1
  • 14
  • 22
1
vote
0 answers

JSONpath in java

JSON file [ { customerId:1}, { customerId:2 }, { customerId:3>} ] in JAVA with Response resp = when().get("link"); i received the json to resp file. Now from the resp file - i'm tring to create a arrray - soo that all the values of the…
nandha
  • 51
  • 6
1
vote
1 answer

Rest Assured support for "text/csv" response

I am using Rest assured to send GET request . The repose is "text/csv" type, is there a way to extract one element value from the csv file using Rest Assured Scenario : I would like to get only "colors" from below CSV Response Car ;wheels ;color…