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 pass AccessToken key in Header in Rest Assured

I have API which is using accesstoken as Header key and Value in Rest Assured Response response = httpRequest.request(Method.POST); //4. get the response body: String responseBody = response.getBody().asString(); …
Vipin Singh
  • 109
  • 1
  • 14
0
votes
1 answer

RestAssured Assertion failing

Feature File Snippet: Then The value of messages.type should be ERROR Actual Service Response: "messages": [ { "type": "ERROR" }] Console Log: JSON path messages.type doesn't match. Expected: a string containing "ERROR" …
0
votes
0 answers

REST ASSURED (JAVA): Extract value form jsonpath and assert it with excel value

public void getAirportDetailswithcity(String eLongitude,String eLaititude,String eCity) { //1. define the base url //http://restapi.demoqa.com/utilities/weather/city RestAssured.baseURI = prop.getProperty("serviceurl1"); //2. define…
Vipin Singh
  • 109
  • 1
  • 14
0
votes
1 answer

How to check if key exists or not using json-path library?

I'm using Json Path library and I want to check if key exists or not and based on that I'll do some actions. Hence I wrote following code - for(int i = 0; i < keyValues.length; i++) { List invalidKeys = new ArrayList<>(); …
Alpha
  • 13,320
  • 27
  • 96
  • 163
0
votes
0 answers

How to fetch values from nested JSON in JAVA using Jsonpath

Below is the JSON response, I have used JSONPath get() to retrieve value of totalContractAmout by using below path - subscriptionQuoteResponseDetails.customerQuoteDetails[0].billPlanQuoteDetails[0].serviceList[0].skuList[0].totalContractAmount But…
0
votes
1 answer

How to upload mutiple images using RestAssured post method

Postman - Post Request api Details for uploading images I am performing POST request for uploading multiple images. Below is a Postman screenshot where everything works fine and I am getting the right response. But then I need to implement the…
Balaji Singh .Y
  • 683
  • 2
  • 9
  • 22
0
votes
1 answer

Getting error code 503 with Rest Assured GET method

I am getting an error code 503 with rest assured GET Method. Here is the code. RequestSpecification request = RestAssured.given(); Response post = request.log().all().relaxedHTTPSValidation().get(url); It is giving me 503 error. The same API works…
0
votes
1 answer

How to reset/remove/clear the request body in rest-assured

I have to pass form-parameter as the body to my request. When I try Response post = request.urlEncodingEnabled(true).log().all().config(RestAssured.config() .encoderConfig(EncoderConfig.encoderConfig() …
0
votes
1 answer

In Restassured Api testing when i run my code why "&" getting added instead of "; " preceding to g=truck

The Actual url is below https://xxa-sa-usedtrucks.abc.com/api/vehicles?itemsPerPage=20&facets=r=US;g=truck For which i get results when i fire. I have slightly changed the above url so that it might work for you as it is confidential. I have written…
Balaji Singh .Y
  • 683
  • 2
  • 9
  • 22
0
votes
1 answer

RestAssured: How to validate response body with JSON schema if response body has extra values?

I am validating json schema using matchesJsonSchemaInClasspath. It is working fine if response body have the same values that are defined in schema.json file. If response body have EXTRA variable / value which is not define in json schema then it…
Wasim
  • 61
  • 1
  • 2
  • 8
0
votes
1 answer

REST-assured | How to get a string value based on matching critera using JSONpath

I need to get count value based on matching critera using REST Assured Jsonpath I tried the following but its not working : response().jsonPath().getString("{it.B == '456'}.B1.size()") JSON : [{ "A": "123", "A1": [{ "A11": "A111" }, { "A12": "A112"…
novice
  • 43
  • 11
0
votes
1 answer

Rest-Assured unable to validate JSON array response

I'm trying to validate that a JSON array contains a certain value. Using Rest-Assured with a hamcrest matchers import in Java. This is the JSON that I'm validating; { "graph": { "groupedResultColumns": [ "Task_Status", …
Ethranes
  • 329
  • 1
  • 5
  • 22
0
votes
1 answer

How do I get a JSON attribute and store it in an array in JAVA?

I am trying to assert in my RestAssured TestNG test that for every given ReportCodeNbr in my JSON file there is a correct UID value. I was able to successfully do this by referencing each json section with a hard-coded index value like in this…
Rainier
  • 11
  • 1
  • 2
  • 7
0
votes
1 answer

RestAssured - Returns result as a Map when retrieving a response of a particular path

The response from my API is { "new": { "new1": "value1", "new2": "value2" } } When I try to get what is there in jsonPath of "new" using response.jsonPath().getJsonObject("new").toString() The above query returns something like below,…
Melvin Richard
  • 403
  • 1
  • 7
  • 15
0
votes
1 answer

RestAssured Json response verification with GPath

I receive the following response on a bad request against my API. I am using RestAssured for my rest response assertions. { "message": "An entity of type topic was passed in an invalid format", "meta": { "display": { …
Ihor M.
  • 2,728
  • 3
  • 44
  • 70