* Difference between API ( jar files accessed locally) and Web Service ( API accessed over the internet are web services)
* Difference between REST ( ? ) and SOAP ( ? )
* https://jsonEditorOnline.org/
* https://www.jsonSchema2pojo.org/
Maven dependencies :
- HTTPclient ?
- HTTPcore ?
- JSON
- TestNG
Static Imports for RestAssured:
import static io.restassured.RestAssured.* ;
import static io.restassured.matcher.RestAssuredMatchers.* ;
import static org.hamcrest.Matchers.* ;
Standard Script:
Response response =
given().auth().contentType(ContentType.JSON)
.basic("sk_test_51HUS4uHSHj7PrP7O8TJxytR1TfTICVAvuHm", "") // token , pswd
.header("Authorization", "Bearer sk_test_51HUS4uH 7O8TJxytR1")
.formParam("' ,"") // as per the api documentation only
.formParam("' ,"") // as per the api documentation only
.param("limit", 3)
.get("https://api.stripe.com/v1/customers");
response.prettyPrint();
//System.out.println(response.asString());
System.out.println(response.getStatusCode());
Two ways to print Response :
- response.prettyPrint();
- System.out.println(response.asString());
- String access_token = response.jsonPath().get("access_token").toString();
- String actual_ID = jsonObject.get("id").toString(); ?
Authentication Types:
- Basic Auth
- Bearer Token
- OAuth 2.0
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.0</version>
</dependency>
No comments:
Post a Comment