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
33
votes
2 answers

Access elements of an anonymous array via JsonPath in RestAssured

I have an anonymous array in JSON returned from a service like: [ {"foo":1, "bar":2 , "baz":3 }, {"foo":3, "bar":4 , "baz":5 } ] How can I access the bar elements e.g. in expect().body("$[*].bar", hasItems(2,4)) I tried a few possibilities…
Heiko Rupp
  • 30,426
  • 13
  • 82
  • 119
13
votes
2 answers

org.apache.http.ConnectionClosedException: Premature end of chunk coded message body: closing chunk expected

I am trying out RestAssured & wrote the following statements - String URL = "http://XXXXXXXX"; Response result = given(). header("Authorization","Basic xxxx"). contentType("application/json"). when(). …
11
votes
3 answers

The import io.restassured.RestAssured cannot be resolved

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…
11
votes
4 answers

How to search/find In JSON with java

I have a below JSON string from the below i want to find/search criteria in JSON String. To find the Number of keys present. To get the values of given key(if we have array) { "store": { "book": [ { …
Ssire
  • 123
  • 1
  • 1
  • 6
8
votes
1 answer

REST-Assured - JsonPath for fetching a list of values

I'm using REST-Assured for testing some RESTful webservices. Here's my JSON: { "status":true, "responseData":{ "orderLevelReasons":[ { "reasons":[ { …
Akshay Maldhure
  • 787
  • 2
  • 19
  • 38
6
votes
2 answers

Capture Network XHR logs(request/response with parameters) with Selenium

I tried to capture Network XHR logs (chrome browser) that generally shows Request(MethodType, Headers, parameters) and Response with Selenium webdriver but i was only able to get api's request that client sent to server(without parameter), while…
5
votes
0 answers

Ideal way to close connections in RestAssured?

I am using RestAssured for API automation. We have a huge application with so many api calls. So, what could be better way to close the connection after response has been received properly. In that way, I will not be worried about connection…
5
votes
1 answer

maintaining sessions with RestAssured

How to set session attributes in restassured? In my application code we have something like this String userId= request.getSession().getAttribute("userid") How to set userId as session attribute here(in restassured test case)? How to maintain the…
Naidu
  • 95
  • 1
  • 10
4
votes
1 answer

Using JSONpath in REST ASSURED java want to extract the data which are in array

The function contains the API in which I can get the value in JSON format. But I want to get the exact ID=2 which is present in JSON How can I get that data using the Java JSON path. I have to use the maven dependency. The function contains the API…
Rohan Kumar
  • 57
  • 1
  • 1
  • 4
4
votes
1 answer

Rest Assured: How do I return JSON response as a String? (Java)

How will I return a JSON response as a String with my code? Purpose : I want to call getAccessToken() after it has obtained the accessToken from a json response body and need to return it as a String to be used in other methods. The response example…
foragerEngineer
  • 149
  • 1
  • 2
  • 13
4
votes
1 answer

RestAssured Parsing Json Array Response using foreach loop

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" }]…
Melvin Richard
  • 403
  • 1
  • 7
  • 15
4
votes
6 answers

RestAssured: java.lang.IllegalArgumentException: Schema to use cannot be null?

I need to compare my api tests response against an external JSON file. Seem to be seeing the following exception: 'java.lang.IllegalArgumentException: Schema to use cannot be null' when executing my api test. My Test: @Test public void…
SamP
  • 417
  • 5
  • 24
4
votes
4 answers

How to assert based on body item with Rest Assured with JSON response?

How can I assert my properties inside the "description" array using the rest assured .body() method. Example: .body ("[0] .userType", equalTo (1)); // error Here is my current JSON data which I want to assert with: { "validSession":…
JJB
  • 115
  • 1
  • 1
  • 7
4
votes
1 answer

RestAssured JsonPath: flat array of elements in hierarchy

I'm writing a smoke test using rest-assured and want to traverse the api to make sure no unexpected errors occur. I have a data structure that looks like this: { ... "sites": [ { ... "groups": [ { ... …
Ranil Wijeyratne
  • 626
  • 7
  • 19
4
votes
2 answers

jsonpath find all object(restassured)

This is my JSON : [ { "id": 9741962, "name": "getName", "isActive": true }, { "id": 1, "name": "New", "isActive": true } ] I want to get all the object that has the name :getName using jsonPath how can I do it using…
Michael Biniashvili
  • 500
  • 1
  • 12
  • 24
1
2 3
25 26