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

Update JSON response from an API and pass the updated response as input/body to another API using Rest Assured

I am currently calling an API using Rest-Assured, whose response body is posted below. i need to pick a portion of the response, i.e. whole of WorkItems tag(at line 3), and update the fields "CorrelationUId" and "Value"(node within…
Sonal
  • 55
  • 8
1
vote
3 answers

JsonPath: find an element in an array by field

I have an anonymous array of objects and I'd like to find an object by a specific field. I tried this: jsonPath.get("$.[?(@.name == 'David')]") but I'm getting the following error: Invalid JSON expression: Script1.groovy: 1: Unexpected input: ' …
IsaacLevon
  • 2,260
  • 4
  • 41
  • 83
1
vote
1 answer

Rest Assured : Failed to parse the JSON document

Failed to parse the JSON document: why I am getting this error. I am trying to pass argument to ajson body to perform a delete operation. The data is stored in an array using TestNg notations. When I run the test, it fails with message "failed to…
1
vote
1 answer

Unable to find/import 'io.rest-assured' packages even after adding to Maven Project

I have added the below dependencies to the maven project pom.xml file and i did a mvn clean, install. I can see the dependencies added to the .m2 folder in my c-drive/users, but they are not listed under the IntelliJ "External Libraries" section.…
1
vote
1 answer

How to get relative path using Groovy Gpath in json?

I am using rest assured with Serenity BDD and using Groovy Gpath to navigate thru JSON. Now, I have a scenario like where I need to get the Cost values more than 2 with below JSON. is there any way to use a relative path to navigate using GPath with…
1
vote
1 answer

How to send array value for one the key for rest assured request

Below is the expected request which should hit the system but while sending it the array becoming string? Expected { "class": "A", "subUsecases": [ "string1", "String2" ] } To generate the above, I am creating the Array object and sending the…
Sobhit Sharma
  • 697
  • 14
  • 45
1
vote
1 answer

In Rest Assured, getString() round off the decimal values after 4 digit

I have scenario, we need to read the latitude and Longitude from json response body. The latitude and longitude has value like below "data": [{ "city": "Mumbai", "country": "India", "latitude": 19.0886993408, "longitude": 72.8678970337 …
Vipin Singh
  • 109
  • 1
  • 14
1
vote
1 answer

New to JsonPath and API Automation. Need suggession on how do i extract value for below JSON with a condition

{ "users":[ { "customerId":"2kXE3upOg5hnOG", "ccoId":"paalle", "userGroups":[ "CX Cloud Super Admins", "CX Cloud Admins", "aAutoGroupMarked12" ], …
Rajaji
  • 133
  • 2
  • 14
1
vote
1 answer

Invalid JSON Expression

I am making use of non-static import JsonPath jp = response.jsonPath(); System.out.println(jp.get("data?(@.id>14).employee_name").toString()); For a JSON as shown below: {"status":"success","data":[{"id":"1","employee_name":"Tiger…
user9261795
  • 363
  • 1
  • 2
  • 8
1
vote
3 answers

Rest Assured java.util.HashMap cannot be cast to class java.util.List

I am working on Rest assured framework to automate API testing. actually I want to get the response as list not as an object. cause I want to do assertions for each element. to check data integrity for each element. I am executing this code: …
1
vote
1 answer

Facing issue in extracting value from nested jsonArray

I know a similar question has been posted, however, the answer didn't work for me. I am new to this RestAssured.I want to get the 'uuid' value if categories equals to 'FUNGI' and feature->features conatains 'VRA'.This is my sample json: [{ …
harry
  • 35
  • 3
1
vote
1 answer

Trouble with Generics in Java

I am using RestAssured framework for api calls and I want to create a method that will return give me value from the JSON response in the specific variable type. I want to use generic return type but I don't like me implementation. The RestAssured…
Leon Proskurov
  • 135
  • 1
  • 14
1
vote
2 answers

how I can use global header request through all tests using rest assured

im new with rest assured and i make make one test to extract access token and some other params and i want to use these access token in the request headers for all other tests is there away to set global header for all test methods i have, or make…
Amr Salem
  • 237
  • 1
  • 6
  • 19
1
vote
2 answers

Multiple matches assertion in JSON via RestAssured

I have several JSON objects in response which contain certain id in each one of them. { "data": [{ "id": 1, "status": { "id": 0 } }, { "id": 2, "status": { "id": 0 } …
1
vote
1 answer

"Application/vnd.api+json" throws "Unsupported Media Type"

I am automating an API for a POST call using Rest Assured and for Content-Type and ACCEPT header I have to use "application/vnd.api+json". But every time I use "application/vnd.api+json" I get 415 status code. Although the same POST call using…
RISHI KHANNA
  • 354
  • 5
  • 23