Book on API Automation with REST assured-Java

602 views
Skip to first unread message

Aha Radio

unread,
Feb 25, 2016, 8:42:39 AM2/25/16
to REST assured
Hi All,

I am new the the Java as well as REST assured.    Is there any book available in the market to learn Rest Assured  for API Automation of my project.

Thanks,
Aha  

Johan Haleby

unread,
Feb 25, 2016, 8:44:34 AM2/25/16
to rest-a...@googlegroups.com
Hi, 

There's no book on REST Assured that I'm aware of but you can read the getting started guide and usage guide.

/Johan

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aha Radio

unread,
Feb 25, 2016, 11:07:57 AM2/25/16
to REST assured
Thanks Johan . 

I am trying to the following for a sample GET Call with URL . i am getting the Error mentioned belwo  ., i am trying to resolve but could not .  

Any help would be appreciated . 

PROGRAM DETAILS & ERROR Details
-----------------------------------------------------------------
package com.sample;
import org.junit.Test;
import static com.jayway.restassured.module.jsv.JsonSchemaValidator.*;
import static com.jayway.restassured.RestAssured.*;
import static com.jayway.restassured.matcher.RestAssuredMatchers.*;
import static org.hamcrest.Matchers.*;

public class SampleTest{
@Test 
    public void getUserData() {
        given().
            contentType("application/json").
            contentType("X-Killbill-CreatedBy: sdp").
            contentType("Authorization: Basic YWRtaW46cGFzc3dvcmQ=").
            contentType("X-Killbill-ApiSecret: sharma").
            contentType("X-Killbill-ApiKey: suraj").

        when().

        then().
            body("email", equalTo("chiran...@gmail.com")).
           statusCode(200);
                    
}

}


with pom.xml 

<modelVersion>4.0.0</modelVersion>
<groupId>com.sample</groupId>
<artifactId>RestAssured</artifactId>
<packaging>jar</packaging>
<version>1.0.0.SNAPSHOT</version>
<name>RestAssured</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.1.0</version>
</dependency>

</dependencies>
<build>
<finalName>apitest</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Version>${buildNumber}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19.1</version>
</plugin>
</plugins>
</build>
</project>
----------------
mvn clean install -U . Getting the following Error   

"<error message="Expected response body to be verified as JSON, HTML or XML but no content-type was defined in the response. Try registering a default parser using:    RestAssured.defaultParser(<parser type>); Content was:  " type="java.lang.IllegalStateException">java.lang.IllegalStateException: Expected response body to be verified as JSON, HTML or XML but no content-type was defined in the response.
Try registering a default parser using:
   RestAssured.defaultParser(<parser type>);
Content was:


at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ........... 
 


Thanks,
Aha

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Johan Haleby

unread,
Feb 26, 2016, 3:08:45 AM2/26/16
to rest-a...@googlegroups.com
Try to log the response, it doesn't seem to be JSON in the response body as you expect it to. 

/Johan
Reply all
Reply to author
Forward
0 new messages