Sunday, August 22, 2021

Post#140-API#9 Parsing Json String using GSON library

 ðŸ‘‡

To use GSON library you have to add maven dependency in your project.

GSON as a Maven dependency looks like this:

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.8</version>
</dependency>

 Let's take the below JSON as an example:

Post#139-API#8 Rest Assured GET Test

 ðŸ‘‡

Before we create our REST Assured tests, make sure that you have added Rest Assured library and TestNG library in your Maven project.

In this tutorial I am using below URL for different request.

https://reqres.in/

Below code snippet shows how to call GET method and test response JSON elements.

package testcase2;

import org.testng.annotations.Test;

import io.restassured.RestAssured;

Post#138-API#7 The components of a URL

 ðŸ‘‡

A URL (Uniform Resource Locator) is a specific type of URI (Universal Resource Identifier). A URL normally locates an existing resource on the Internet. A URL is used when a web client makes a request to a server for a resource.

Briefly, a URI is defined as any character string that identifies a resource. A URL is defined as those URIs that identify a resource by its location or by the means used to access it, rather than by a name or other attribute of the resource.

Saturday, August 21, 2021

Post#137-API#6 Idempotency with HTTP Methods

 ðŸ‘‡

What Is Idempotent in REST?

In the context of REST APIs, when making multiple identical requests has the same effect as making a single request – then that REST API is called idempotent.

An idempotent HTTP method is an HTTP method that can be called many times without different outcomes. It would not matter if the method is called only once, or ten times over. The result should be the same.

Idempotency with HTTP Methods

If you follow REST principles in designing API, you will have automatically idempotent REST APIs for GET, PUT, DELETE, HEAD, OPTIONS and TRACE HTTP methods. Only POST APIs will not be idempotent.

Post#136-API#5 HTTP Methods

 ðŸ‘‡

Before we start scripting with Rest Assured Lets understand what are these methods GET, POST, PUT, PATCH , DELETE etc.

GET

GET requests are the most common and widely used methods in APIs and websites. Simply put, the GET method is used to retrieve data from a server at the specified resource. For example, say you have an API with a /users endpoint. Making a GET request to that endpoint should return a list of all available users.

Idempotent REST APIs

In the context of REST APIs, when making multiple identical requests has the same effect as making a single request – then that REST API is called idempotent.

An idempotent HTTP method is an HTTP method that can be called many times without different outcomes. It would not matter if the method is called only once, or ten times over. The result should be the same.