From the course: Java: Automated API Testing with REST Assured

Anatomy of a request - Java Tutorial

From the course: Java: Automated API Testing with REST Assured

Start my 1-month free trial

Anatomy of a request

- [Instructor] The communication between APIs, consists of two parts, a request, and a response. In this chapter we'll focus on the API request. Before we dive in too deep, let's discuss the anatomy of an API request to ensure we have a common vocabulary for these concepts. An API request is essentially comprised of four components. The endpoint is a URL. This is where our request is sent for processing. In this example, our endpoint is the update category functionality of the application. As you can see, this alone is not enough to determine what exactly our request is. Because the application does not know what it is we'd like updated. Which is why the additional pieces of the requests are needed. Such as the method. Which indicates the type of action we would like to take. And the headers, which specify any authorization credentials that may be required to make the request as well as other pertinent information. Such as, the format of how we like to receive our response. And last but not least, the data. This is an optional part of the requests that can be provided if there is additional information the API will need in order to fulfill our request. So, if we're making a request to delete a product, we need to specify which product we'd like deleted. The approach to providing this data varies. It can be provided via query parameters, or via a body. Also sometimes referred to as a payload.

Contents