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
11
votes
4 answers

POST request in rest assured

I am using rest assured for the post request containing the JSON body My post request code is :- RestAssuredResponseImpl stat= (RestAssuredResponseImpl)given(). header("Accept", "application/json"). …
11
votes
4 answers

How to search/find In JSON with java

I have a below JSON string from the below i want to find/search criteria in JSON String. To find the Number of keys present. To get the values of given key(if we have array) { "store": { "book": [ { …
Ssire
  • 123
  • 1
  • 1
  • 6
11
votes
7 answers

How to test Rest API which require authentication using Rest assured

I want to test a Rest API which require authentication, before getting the Json response. FOr exa. If i want to visit rest API: http://192.168.xx.xx:9000/dashboards/all/list/m1/p1/sch1 then if I am not already logged in , then this will redirect…
undefined
  • 3,464
  • 11
  • 48
  • 90
11
votes
4 answers

How to get rest-assured log into something printable in a text file

I'm working into a method trying to change the default rest-assured log (which goes to the console) to a file using log4j. It's a JUnit project which methods finally call to a REST facade, which have methods like this one. private…
user2003186
  • 141
  • 1
  • 1
  • 5
10
votes
2 answers

using a Json file in Rest-assured for payload

I have a huge JSON file to be POST as payload of a rest api call for testing purposes. I tried something like : public void RestTest() throws Exception { File file = new…
Bhaskar Mishra
  • 3,332
  • 7
  • 26
  • 36
10
votes
3 answers

Hamcrest matcher with slashes is interpreted as a part of validation

I have the following validation where I have to check if returned body has a string containing "id": 6354, but it interprets slashes of special characters. How I can validate strings which contain double quotation marks ? Code import static…
ashur
  • 4,177
  • 14
  • 53
  • 85
10
votes
3 answers

Empty respond body for post with rest assured

I am using restassured with junit4. In my test method i create a object in mongodb and when i run the test it successfully persist also. But i need to store the id created so i try to get the respond body. But the response.getBody().asString() is…
Harshana
  • 7,297
  • 25
  • 99
  • 173
10
votes
1 answer

How to initialize multiple RestAssured url in the same project without overriding each other?

I have multiple modules within same project which needs to communicate with entirely 2 different REST API systems. I want to use Rest Assured for both. The problem I am facing here is if I use the code for setting the baseuri (RestAssured.baseURI)…
Vikas
  • 404
  • 5
  • 18
9
votes
3 answers

Extract the contents of a plain/text in rest assured

I am getting a response from my RestAssured call as ContentType text/plain;charset=UTF-8. I searched the internet but am unable to find a nice way to get the content out of the message as using the below is not so nice; String content =…
Jurn
  • 796
  • 1
  • 8
  • 19
9
votes
5 answers

Rest Assured Bearer authentication

I am new to using Rest Assured,Java and Api testing so please be gentle with me. When I use rest assured to test an api that uses Bearer authentication the tests fail resulting in:- java.net.ConnectException: Connection refused: connect I know the…
Klugsman
  • 91
  • 1
  • 1
  • 4
9
votes
4 answers

Not able to connect to server through java code. Getting javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

I am trying to build a Test Automation Tool for REST API on AWS using rest-assured framework. I just tried with a simple HTTP POST and checking the output JSON body. But when I run that in Eclipse I get SSLHandshakeException. I did try to look into…
kaizen
  • 108
  • 1
  • 1
  • 7
9
votes
4 answers

how to see actual body sent from restassured

I have created a jax-rs rest api and tested it with rest-assured. All tests are green. Now I am trying to create an html/js front end for it. My problem is I do not know how my json objects should look like to be accepted by my rest api. Thanks to…
dermoritz
  • 12,519
  • 25
  • 97
  • 185
9
votes
1 answer

How to use REST assured?

I have never used JUnit or other testing frameworks. All i know is how to develop rest service. I recently saw REST assured framework to test REST api. But all the articles that i found looks like below. But i don't know how to pass request xml and…
Manoj
  • 5,707
  • 19
  • 56
  • 86
8
votes
5 answers

Conflicting module versions. Module [groovy-xml is loaded in version 4.x.x and you are trying to load version 3.x.x

I am working to setup wiremock for springboot rest api and using rest assured and spring-cloud-starter-contract-stub-runner from spring cloud. when i run the sample integration test i encounter module conflict error
Guru Cse
  • 2,805
  • 2
  • 18
  • 15
8
votes
1 answer

"Receiver class does not define or inherit an implementation" with RestAssured 4.3.0

When running the following WebTestClient test @Test fun `test accepted response`() { standaloneSetup(SapKontraktEndpointV1()) given() .body( "{}", ObjectMapperType.JACKSON_2 ) …
Andras Hatvani
  • 4,346
  • 4
  • 29
  • 45