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
3 answers

How to validate a list of values from the response using RestAssured

Could someone please me understand how to validate a list of items from the response. Say the response looks something like below, { "store":{ "book":[ { "author":"Nigel Rees", …
2
votes
3 answers

How to pull the last jsonPath value in Java?

Hello I wanted to ask how to retrieve the last value in a jsonPath { "testing": [ { "transactionId": "5a99dcf84b7f633a5489805d", "trackingId": "555112", "tn": "6095555112", "customerName":…
JayC
  • 2,144
  • 8
  • 42
  • 77
2
votes
1 answer

RestAssured - JsonPath filter a matching Object's properties from an array of objects, given a filter criteria

I am writing an integration test to my microservice using rest assured. I have a Json payload like this which is returned from it. { "sessionQuestions":[ { "id":1272, "sessionId":1146, "questionId":"1002", …
Ravindra Ranwala
  • 20,744
  • 6
  • 45
  • 63
2
votes
0 answers

how to escape at sign (@) in groovy gpath

I have a very specific use case while using rest-assured for testing REST API. I would like to retrieve a value of '@odata.type' from following JSON response; { "value": [ { "@odata.type": "#example.type1.", …
2
votes
3 answers

Rest Assured: Extracting value from JSON Array

I am trying to extract values from JSON array with rest assured using jsonPath. Example JSON Response: { "notices": [], "errors": [ { "code": "UNAUTHORIZED" } ] } Current test is below: @Test(dataProvider =…
Andrew Nolan
  • 1,987
  • 2
  • 20
  • 23
2
votes
1 answer

Rest-Assured - json body assertion for set of values in list regardless of position

I am using rest-assured to test a rest api. I have a json response that returns an array of objects. I want verify that it contains objects with specific test of values. Check the following example: Example JSON: { "contents" : [ { …
Panos
  • 7,227
  • 13
  • 60
  • 95
2
votes
2 answers

RestAssured JsonPath: How to filter json objects from json

I'm trying to take an array of objects from json file and i have an issue. path.get("wgcTournaments.items") What path i should use to get all items(item0, item1, item2 ...) in items? Can you please give me an advice how to do it. Json example { …
Roman
  • 91
  • 1
  • 10
2
votes
1 answer

RestAssured JsonPath: Issue with getting data from json

I need to take a data from json file which has a weird structure and i can't find a solution for it. I'm using restAssured with jsonPath and when i'm trying to get data for particular week like…
Roman
  • 91
  • 1
  • 10
1
vote
1 answer

How to verify the response headers in Rest Assured framework

How to verify the response headers in Rest Assured framework? I tried the below way to check for response headers, but my code is not giving any result. Util file public void verifyResponseHeaders(Map data { softAssert =…
1
vote
0 answers

RestAssured RequestSpecificationImpl body method removing "is" from the fieldName

I have the Feature class as follows: public class Feature { private FeatureType featureType; private Integer featureNumber; @JsonProperty("isActive") private boolean isActive; @JsonProperty("isAutomatedFeature") private boolean…
SanQA
  • 233
  • 3
  • 9
1
vote
0 answers

Change date from JSON file for RestAssured in Java

I have a json file which I am passing within api request - which is working but I need to have the date passed as dynamic as per this from current date: final LocalDate plus180Days = LocalDate.now().plusDays(180); here is the sample json file I…
gg_man
  • 11
  • 3
1
vote
1 answer

How do we assert the JSON response field type (if it's String or int)?

How do we assert the JSON response field type? { "Data" : [ "Id" : 1, "Name" : "ABC" ] } Is there any way to validate that ID should contain an int and Name should be a String? I don't want to validate the values.
Bob
  • 11
  • 1
1
vote
0 answers

How to use data structures to pass Input and Verification in JSON format file in the Rest Assured framework?

How to use data structures to pass Input and Verification in JSON format file in the Rest Assured framework. In the below file I am passing the Username and password as the input as the payload and verifying different User types from the JSON…
1
vote
1 answer

Why am I getting the error "java.lang.NoSuchMethodError: 'org.hamcrest.Matcher" while running the code with RestAssured java libraries?

I am getting the error for ResponseLoggingFilter in Rest Assured framework while running the code with RestAssured java libraries. I am using the 4.5.1 rest assured version in the POM file. Has anybody faced the similar issue? Need…
1
vote
1 answer

How to use HashMaps in RestAssured if I want to extract the JSON response value and avoid using static variables at the beginning?

Right now I am using the JSON path function to get the JSON response values like placeid, profileid and then am declaring that as static, because I need to use those variables in clickProfile() and clickPlace() functions. Going forward I will have a…