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

How to send the nested JSON in body for POST method using Rest-assured

I have a long JSON body which is an array. I need to send this in the body for POST method. I am using Rest-assured. How to do it?
Dhruv Bhatnagar
  • 121
  • 5
  • 17
0
votes
1 answer

Rest Assured code not allowing to use println

I am trying to automate twitter API. when tried to print "js.get("text") using System.out.println(js.get("text")); I am getting error as "The method println(boolean) is ambiguous for the type PrintStream" I downloaded jars and passed in Build…
Madhusudhan R
  • 301
  • 1
  • 5
  • 17
0
votes
1 answer

restassured jsonpath findAll not working as expected

I'm trying to implement a method on java rest assure that find a value querying a JSON file. For this, I use a findAll method for JSONPath from the library io.restassured.path.json.JsonPath in order to access the value needed. for some unknown…
Luis Urea
  • 107
  • 3
  • 12
0
votes
0 answers

Getting error while assertion Expected: iterable containing ["IT"] Actual: IT

I am using cucumber to define my test script and in one of my test steps is below **And response Get Countries and Cities names |Response.Data["countries_and_cities_names "][0].language_code | IT | ** glue code behind is @And("response Get…
0
votes
3 answers

Getting String value using JsonPath Java

Im using JsonPath to Assert on some of the values returned from an api response but having a small issue with asserting the response. Heres the response i get: [{"Id":75969,StartDate":"2016-07-01","EndDate":"2021-04-30","duration":5640}] Lets say i…
bobe_b
  • 187
  • 1
  • 2
  • 21
0
votes
4 answers

Getting unique attributes from a JSON API using Rest Assured

I have an API , which gives a JSON response like this [{ "records": { "0": { "id": 123, "emp_type": "P", "emp_level": "8", "emp_id": "12345" }, "1": { "id": 132, "emp_type": "Q", …
demouser123
  • 4,108
  • 9
  • 50
  • 82
0
votes
1 answer

RestAssured creates two consequent requests for POST and returns 401 error

I'm trying to send a POST request with payload (xml). Here is my code example: val xml = """ | ........ ........ """.stripMargin RestAssured.baseURI = "https://xxxxxxxxx" val request:…
27P
  • 1,183
  • 16
  • 22
0
votes
1 answer

Rest Assured - How to Validate Json response value based on value of previous Json node

In Rest Assured , I send a get request and below Json response is received. //Json Response { "data": [ { "Name": "REST", "Description": "Representational state transfer" }, { "Name": "SOAP", "Description":…
0
votes
0 answers

In Rest Assured Framework POST response is not showing ID created and Time that I am getting through POSTMAN

In Rest Assured Framework POST response is not showing ID created and Time that I am getting through POSTMAN. @Test public void newuser() { service = new services(); // response = service.addProduct("444", "OIL","Natural Tea Tree",…
0
votes
0 answers

How to Parse Anonymous array of JSON in java to get the value of a JSON key in java?

I want to print the value of "isbn" the in below JSON body using jayway.restassured.path.json.JsonPath and not by any other library. As you can see below, there is no name present for the given JSON array which is having only 1 element. [ { …
Brenda
  • 7
  • 1
  • 7
0
votes
1 answer

How to calculate the sum of a Respond (Json) using response.path?

Seem to be struggling to calculate the number of squad members who have the role type of 'PLAYER' by performing my restassured logic against my Json response. Currently I have a simple setup which hits an endpoint and then executes my query, I can…
SamP
  • 417
  • 5
  • 24
0
votes
2 answers

What should be the java code for rest-assured api for getting the access token

I want to get access token from the given REST-API call. I have tested this in postman and it is working fine which needs data to be entered in all 3 tabs( Authorization, Header and body and need to fire post method). Please find the attached…
0
votes
0 answers

post application/x-www-form-urlencoded request by using rest assured

I've tried in postman successfully,by adding Header"Content-Type=application/x-www-form-urlencoded" with x-www-form-urlencoded body.Apparently, this was my first time working on rest. Please advise me that below my code is correct or not. Thank…
Checo
  • 1
  • 3
0
votes
1 answer

How to print jsonpath for json object

I am looking for java API which prints jsonpath for all fields in json object. My 1st part of requirement is like, for given json object (or string) - { "store": { "book": [ { "category": "reference", "author":…
0
votes
1 answer

How to update json using io.rest-assured

String jsonString = " { "success": true, "total": 282, "timeTaken": 31, "responseCode": 200, "facet_count": {}, "inferred": { "city": null, "locality": null, "cityList": null, "state": null } } "; Problem : To update "locality" value…
user522170
  • 623
  • 1
  • 6
  • 21