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

HTTP POST Request using Rest Assured (Example)

Below POST Method can be used to run the HTTP POST request in Rest Assured using Java better to go with GSON dependency { RestAssured.baseURI = API_URL; RequestSpecification request = RestAssured.given(); request.header("Key1",…
1
vote
1 answer

Rest Assured: Isn't there a better way to test an array of results?

I am studying Rest Assured framework now. Using some API I get the following (partial) JSON response: { "results": [ { "type": "AAAA" }, { "type": "A" } ] } I am trying to verify the…
dushkin
  • 1,939
  • 3
  • 37
  • 82
1
vote
1 answer

How to convert jsonarray into map or something else format which can be compared with datastax value

I have JSON Array which I want to convert in some format which I can compare with datastax value. I tried below code: String familyNames = response.jsonPath().getString("FAMILY"); and List jsonresponse = response.jsonPath().getList("$"); I am not…
Dolly
  • 97
  • 3
  • 18
1
vote
1 answer

Getting a 14 decimals number from JSON with JAVA

I have a JSON source from an API at work, where I have to get a balance from the JSON response, so the value is very important. That amount comes in xx.xxxxxxxxxxxxxx (usually two digits followed by a maximum of 14 decimals). I am working with…
1
vote
2 answers

Hamcrest closeTo not working in RestAssured.body()

I have a test that I cannot get the syntax correctly: @Test void statsTest() { given().queryParam("param", "ball") .when().get() .then().body("total", is(closeTo(10.0, 0.1*10.0)))); } However, the test keeps failing even…
Shejo284
  • 4,541
  • 6
  • 32
  • 44
1
vote
1 answer

Getting all ids from a JSON response using Rest Assured

I have recently moved to test API's for a new project with Rest Assured. I am not so fluent in Java, so that is why I need to know how to optimise the code. Let's say I have an API, which output's JSON in this format - { "records":[ 0: { …
demouser123
  • 4,108
  • 9
  • 50
  • 82
1
vote
0 answers

expectBody("", is(2)) vs expectBody(is(2))

I was expecting this 2 invocations to produce the same result, however I'm getting different results. expectBody("", is(2)) // empty path expectBody(is(2)) // no path My context is too big to copy here, but I got this example from the…
Roberto Morávia
  • 492
  • 1
  • 6
  • 13
1
vote
1 answer

How to create a simple json template to send body data with restassured?

So i am trying to build a json to send data to the body of my restassured request, like this structure here: { "id": 1, "category": { "id": 1, "name": "duch" }, "name": "benny", "photoUrls": [ "string" ], "tags": [ { …
totothegreat
  • 1,633
  • 4
  • 27
  • 59
1
vote
0 answers

Assertion failure while using containsInAnyOrder

I am trying to extract Json response as a list of type string in the code below- List titleTypeAssertions = response.getBody().path("content.items.type"); upon System.out.println(titleTypeAssertions); below is the result- it is clearly…
Raj
  • 95
  • 1
  • 3
  • 13
1
vote
0 answers

Search for RestASSURED values by sending a variable

In the following code fragment I am trying to find in my responseBody a specific number by a variable and thus save its brother value. However when I try to do it that way he answers me null and if I remove the quotes he answers me: The parameter…
1
vote
2 answers

Nested iteration over JSON using groovy closure in REST-assured

I have the following JSON response for my REST endpoint: { "response": { "status": 200, "startRow": 0, "endRow": 1, "totalRows": 1, "next": "", "data": { "id": "workflow-1", "name": "SampleWorkflow", …
riyasvaliya
  • 745
  • 6
  • 8
1
vote
1 answer

Rest Assured error parsingMessage: "Invalid UTF-8 middle byte 0x20"

I have a problem to validate a schema json in specific situations, but i use this similar code in other test cases and i have sucess. Follows exemple where i dont have sucess to validate schema: This code i using: given() .header("Accept",…
1
vote
2 answers

Rest Assured - comparing the json path with another

I have json for example below {"TestJson":{ "Result":"Passed", "description":"Passed."}, "Students":[{ "Class":{ "Primary":"Yes" }, "Course":{ "Enrolled":"yes", "AccountNumber":"2387287382" …
1
vote
1 answer

Swagger content serialization to java POJO

I'm wondering is there any tool to generate Java POJO from swagger content/parameters? My problem is, the request/response is huge in json format. Especially the response and I'm not sure what is the best way to handle them with…
1
vote
1 answer

JsonPath Query for Rest Assured

API URL : https://davids-restaurant.herokuapp.com/menu_items.json?category=C I'm trying to retrieve name property of ID 913 from the above rest API Please find my code below String URL =…
user7520525