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

response.jsonPath() has square brackets around the element, how do I retrieve the string value? Rest Assured

I have an HTTP response body that looks that this when I make a GET request: [ { "id": "1111", "type": "Sale", "name": "MyNameTest", "shortDescription": "Sale a" } ] When I try to assert the results with "Rest Assured", the…
R111
  • 151
  • 1
  • 6
  • 14
2
votes
0 answers

Assert each flag in rest assured array is equal to True/False

I have response that is a list of buildings, each of these buildings have a flag which is either true or false. How could I iterate through this response and assert that every one of these flags is equal to true or false? jsonPath =new…
itadaki33
  • 65
  • 1
  • 8
2
votes
1 answer

Fake API Automation: Assertion is not working

I am testing a fake API https://jsonplaceholder.typicode.com/ These are the following tasks: Get a random user (userID), print out its email address to console. Using this userID, get this user’s associated posts and verify they contain a valid…
Baadal
  • 21
  • 3
2
votes
1 answer

RestAssured - JsonPath expression filter not working

{ "success": true, "code": 200, "message": "Success", "payload": { "data": [ { "_id": "123", "state": "Archived", "version": "2", "name": "Sample", …
pramod
  • 21
  • 1
2
votes
2 answers

When I attempt to match a double value from a json array it fails with the expected value having angle brackets around it. What does this mean?

Using RestAssured I attempt to check the following piece of JSON: { "id": "abc1", "commonName": "Plane", "location": [ 1.1, 1.1 ] } with the following piece of java code: double[]…
user1098798
  • 313
  • 3
  • 14
2
votes
0 answers

Find a node by name in RestAssured JPath

I got the following JSON { "response":{ "id":"XYZ", "header":[ { "nat":"1" } ], "summary":[ { "recordCreationDate":"29-Aug-2018", …
user3727540
  • 922
  • 3
  • 11
  • 30
2
votes
3 answers

Accessing jsonpath elements with nested objects

I am looking to extract certain values from a JSON path of arrays and objects and use these values for further processing and am struggling with accessing those elements. Here is the JSON response: [ { "od_pair":"7015400:8727100", …
Mihir
  • 491
  • 5
  • 21
2
votes
1 answer

Getting element value from jsonpath whose root is an array

I have a JSON response which has root as an array of 1 or more objects. I want to extract the value of one of the elements within each object. Here is the JSON sample: [ { "od_pair":"7015400:8727100", "buckets":[ { …
Mihir
  • 491
  • 5
  • 21
2
votes
1 answer

Is there a way to find a JSON response element value based on another element value?

Using the below method i could get the "id" element(first element in first list) value. i need to get that element value but based on the condition of another element "gifts.nameEn" Response response =…
2
votes
2 answers

REST ASSURED (JAVA): Extract json object value given it's parent object value

Suppose I have the following json: { "page": 2, "per_page": 3, "total": 12, "total_pages": 4, "data": [ { "id": 4, "first_name": "Eve", "last_name": "Holt", "avatar":…
Eyal Sooliman
  • 1,876
  • 23
  • 29
2
votes
2 answers

Find specific key-value pair in an array of object with rest assured

I have a json response something like this: "someArray": [ { "someProperty":"someValue", // other properties that are not relevant for me }, { "someProperty":"someOtherValue", // other properties that are not…
Hienz
  • 688
  • 7
  • 21
2
votes
1 answer

How to get first element from jsonpath using index in rest-assured framework?

My api response: { "123": { "userId": 424, "firstName": "abc", "lastName": "xyz", "username": "abc", "email": "abc@gmail.com", "status": 1 }, "234": { "userId": 937, …
user2884776
  • 53
  • 1
  • 1
  • 8
2
votes
2 answers

Getting assertionError using restassured on Json repsonse field value and the expected and actual are identical

Here is my code after getting the response. response.then().assertThat().body("documents[0].items[0].price.sales_tax_summary[0].rate",equalTo("0.0")); here is the response log: { "id": "quote-1", "documents": [ { "id":…
Omar Sabha
  • 23
  • 5
2
votes
3 answers

Rest Assured - Extract a single value from a list of multiple records with GPath

I have a list of records: { "StatusCode": 200, "Result": [ { "Id": 15015600, "Amount": 97.41, "CreatedDate": "10/17/2018", }, { "Id": 15015602, "Amount": 682.11, "CreatedDate": "10/17/2018", …
Anton
  • 761
  • 17
  • 40
2
votes
1 answer

Problems matching a long value in Rest Assured json body

I have the following response: [ { "id": 53, "fileUri": "abc", "filename": "abc.jpg", "fileSizeBytes": 578466, "createdDate": "2018-10-15", "updatedDate": "2018-10-15" }, { "id":…
CodeChimp
  • 8,016
  • 5
  • 41
  • 79
1 2
3
25 26