Questions tagged [rest-assured]

REST Assured is a Java library that provides a domain-specific language (DSL) for writing powerful, maintainable tests for RESTful APIs.

REST Assured enables testing of REST services in Java.

It uses a fluid syntax inspired by similar libraries for and .

2207 questions
5
votes
2 answers

Rest Assured Exception when test fails

I have a simple rest-assured test that is verifying this json comes be with the correct data for a call. I am using rest-assured 1.8 and did swap the groovy jars for the groovy-all jar due to a known issue with 2 different versions of ASM. My json…
user2884037
  • 51
  • 1
  • 1
  • 3
5
votes
4 answers

REST Assured and multiple posts

I'm trying to use REST assured to test my login/logout feature. Is it possible to have a REST assured test that posts to login then posts to logout? If not, how can I test it properly?
mattklamp
  • 293
  • 4
  • 13
5
votes
2 answers

Issue with i/o No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer

not sure whats going on, the full error is: Problem with i/o No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS)…
user1684462
4
votes
1 answer

Using JSONpath in REST ASSURED java want to extract the data which are in array

The function contains the API in which I can get the value in JSON format. But I want to get the exact ID=2 which is present in JSON How can I get that data using the Java JSON path. I have to use the maven dependency. The function contains the API…
Rohan Kumar
  • 57
  • 1
  • 1
  • 4
4
votes
1 answer

How do I configure RestAssured http client to use socks proxy?

Apparently rest-assured misses support for socks proxies: https://github.com/rest-assured/rest-assured/issues/934. Is there way to overcome this and despite all connect through proxy?
Radek Postołowicz
  • 4,506
  • 2
  • 30
  • 47
4
votes
1 answer

Rest Assured: How do I return JSON response as a String? (Java)

How will I return a JSON response as a String with my code? Purpose : I want to call getAccessToken() after it has obtained the accessToken from a json response body and need to return it as a String to be used in other methods. The response example…
foragerEngineer
  • 149
  • 1
  • 2
  • 13
4
votes
3 answers

RestAssured does not respect ObjectMapper configuration in Quarkus

I've made a very simple adjustment to the ObjectMapper configuration in my Quarkus application, as described per the Quarkus guides: @Singleton public class ObjectMapperConfig implements ObjectMapperCustomizer { @Override public void…
romatthe
  • 1,447
  • 3
  • 17
  • 33
4
votes
1 answer

RestAssured Parsing Json Array Response using foreach loop

I have response from RestAssured which is a JsonArray looks similar to the below code [{ "id": "1", "applicationId": "ABC" }, { "id": "2", "applicationId": "CDE" }, { "id": "3", "applicationId": "XYZ" }]…
Melvin Richard
  • 403
  • 1
  • 7
  • 15
4
votes
0 answers

Which matcher should I use in restassured to match number like 1.0

I'm using restassured and org.hamcrest.Matchers. I have the following response from my api { "entity" : { "value" : 1.0 } } in my tests I have the following code given() .headers(createHeaders()) .when() .get(url) …
alekz
  • 116
  • 9
4
votes
0 answers

Wrong encoding on header response Java

I am try to do POST REQUEST to api, let say the API will return a response header in thailand character 10,000 บาท. after i do the request the response i am getting the header value is 10,000 à¸à¸²à¸. Here is the code: RequestSpecification…
4
votes
6 answers

RestAssured: java.lang.IllegalArgumentException: Schema to use cannot be null?

I need to compare my api tests response against an external JSON file. Seem to be seeing the following exception: 'java.lang.IllegalArgumentException: Schema to use cannot be null' when executing my api test. My Test: @Test public void…
SamP
  • 417
  • 5
  • 24
4
votes
1 answer

Test if an array contains an element from another array with Hamcrest

I actually have two types of data: a = ["1", "2", "3", "3", "5"] b = ["7", "2"] given() .header("Content-Type", "application/json"). when() .post(this.url). then() .statusCode(200) .contentType("application/json") …
Betcha
  • 155
  • 3
  • 12
4
votes
2 answers

Response.toString() returns io.restassured.internal.RestAssuredResponseImpl@46320c9a instead of Response body string

I am using GSON to serialise and deserialise JSON response while supplying as payload and mapping response to the data model. Now, here id is auto-incremented from DB so we don't need to pass when creating payload. JSON payload:…
DIPESH
  • 67
  • 1
  • 2
  • 9
4
votes
3 answers

REST-assured: verify that a JSON object contains all Strings from a List

I have constructed a list that contains Strings of a JSON object's body field names like this: List fieldNames = new ArrayList(); Then I have used REST-assured to GET a response which is in JSON format like this: { "id": 11, …
Clx3
  • 119
  • 1
  • 1
  • 11
4
votes
1 answer

In REST Assured, how do I solve UnrecognizedPropertyException when mapping response to an object?

I am new to REST Assured API testing, I have already added jackson-databind, jackson-annotations and jackson-core All 2.9.6 versions to the library. Below is my code: public class SerializeAndDeserialize { @Test public void…
Aakash Goyal
  • 305
  • 1
  • 4
  • 22