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
3
votes
1 answer

How to use query parameter with different combination in rest assured in Java?

I have 6 query parameters. All of them are optional. How should I use them with all combinations? I tried the following: do { Response searchbyfield = given() .headers("Cookie", cookies) .queryParam("search","test") …
3
votes
2 answers

POST request fails (rest-assured test) Expected response body to be verified as JSON, HTML or XML but no content-type was defined in the response.?

I have problem with making POST request with rest-assured. @Test public void deleteBook(){ //Given Response response = given(). contentType("application/json"). body(" { \"Title\": \"Libro2\"}"). when(). …
DIP
  • 31
  • 1
  • 3
3
votes
3 answers

RestAssured: get key value from json object with specified value

In a test case I perform a call with the following response: [ { "ourID": "770050010000000010", "date": "2019-03-07", "otherValue": null }, { "ourID": "770050010000000020", "date": "2019-03-07", …
3
votes
0 answers

Getting "JSON path ... doesn't match" when running REST Assured custom Hamcrest matcher

I am new to REST Assured and my objective is to create a custom Hamcrest Matcher which accepts java object(Item; as referred below) created by me. This is the class that extends the TypeSafeMatcher abstract class. import net.example.Item; import…
kaweesha
  • 803
  • 6
  • 16
3
votes
2 answers

Extracting nested value from Rest Assured response

I need to extract and/or assert against the values under "fields" (ie. "consent", "failure count") in the following json response body: { "next": null, "previous": null, "results": [ { "huid": "be7d-794186bda2d3", "name": null, …
3
votes
2 answers

What is the Rest Assured proper JsonPath get() format for selecting the value of a field within an array of JSON objects

I am using rest assured to make an API post call and getting a response back in the body. I then need to take this response and select specific field values and store them as strings to be compared later against other string objects. I wrote…
D-Money
  • 137
  • 1
  • 12
3
votes
1 answer

Using REST Assured, how can I check if a field is present or not in an array of json objects type of response?

I need to validate that a response like the one below contains some fields. I am not interested in the fields value - just that the keys exist. For example I want to check that the key "id" is present in this type of response. How would I accomplish…
3
votes
2 answers

Class not Found org/hamcrest/TypeSafeMatcher

I am trying to create a project using Rest Assured with TestNG, but I am running into an issue with java.lang.NoClassDefFoundError: org/hamcrest/TypeSafeMatcher . Rather new to this, so any help is appreciated. I am using Maven:
Andrew Nolan
  • 1,987
  • 2
  • 20
  • 23
2
votes
1 answer

Using REST assured with Java Hamcrest to check if Array contains item with multiple key value pairs where the values have a different type

An api returns an array with json objects. I want to check if an object in the array exists which has certain key value entries. The approach im using does not work when the value type is different. "$", hasItem( allOf( hasEntry("id",…
2
votes
1 answer

Deserialization for list of objects is not working with Rest Assured Jsonpath and jdk8

I have a Rest Endpoint that returns the below response { "incentives": [ { "incentiveId": "271230", "effectiveDate": "2022-06-01T07:00:00.000+0000", "expiryDate": "2022-10-01T03:00:00.000+0000", "incentiveName": "$500…
2
votes
1 answer

How to remove an attribute from RequestSpecification/FilterableRequestSpecification body?

Dears, I am working on creating a simple method which will take String argument which will be a path or other kind "pointer" to attribute/s in JSON and this method will remove those attribute/s. My problem is I can find values of those attribute/s…
2
votes
1 answer

RestAssured : annot determine how to serialize content-type application/x-www-form-urlencoded. How to create request with key/value structure?

I have the following postman collection : { "info": { "_postman_id": "b172f7d9-xxxxxxx", "name": "protection", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ …
Valentyn Hruzytskyi
  • 1,772
  • 5
  • 27
  • 59
2
votes
1 answer

java.lang.NoClassDefFoundError: io/restassured/path/xml/mapper/factory/JAXBObjectMapperFactory

I'm trying to run a Cucumber test-case scenario and received an error after compilation in IntelliJ-IDEA. I have posted the build.gradle file here. I'm not sure why I'm getting this error as soon as I run the program. Can somebody enlighten me on…
2
votes
1 answer

Getting specific data from JSON response using Rest-Assured and java

How can I get the sub-nodes EntityPropertyValue,ProductPropertyValueUId,ProductPropertyValueDisplayName that come under the parent node ["Name": "PriorityUId"] using Rest Assured ? Below is the code snippet RequestSpecification request =…
Sonal
  • 55
  • 8
2
votes
1 answer

Rest assured - How to validate JSON response field with the same name

I have the sample JSON response "userinfo": [ { "userName": "name1", "registered": false }, { "userName": "name2", "registered": true …
HenlenLee
  • 435
  • 1
  • 11
  • 30
1
2
3
25 26