# GET

Handle a GET request in Spring Boot with @GetMapping, return the categories as JSON, and check it from Insomnia.

Journeyman · Spring Boot · REST API · Updated November 14, 2026

Requesting data from a REST API is done through a `GET` request.

![A GET request is a header only: the verb GET and an address such as http://localhost:8080/categories, /categories?name=Sports or /categories/10](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/09/72c2b0e1db12474e8c44ac67e6bc53fa.png "A GET request is a header only: the verb GET and an address such as http://localhost:8080/categories, /categories?name=Sports or /categories/10")

The server retrieves and returns the data.

![The server answers with status 200 (success) and a body holding the categories as a JSON array](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/09/20aadf0e559c4214a6b199fa782d70c4.png "The server answers with status 200 (success) and a body holding the categories as a JSON array")

## GET Request - Client

In Insomnia, this is your `All categories` request from *Insomnia: GET*:

```text
GET {{ _.base_url }}/api/categories
```

## GET Request - Server

When a client makes a request, the server directs it to a controller. The method that handles the request must be marked with the `@GetMapping` annotation. Add this method to your `CategoriesController`:

```java
@GetMapping(path="/api/categories")
public List<Category> getAllCategories ()
{
  //use the DAO to get all categories
  return categoryDao.getAllCategories();
}
```

## GET Response - Client

Run the app again in IntelliJ, and send `All categories` from Insomnia. The `404 Not Found` from *Insomnia: GET* is now `200 OK`, with every category as a JSON array: the answer you wrote down.

![Insomnia shows 200 OK and a JSON array of categories, starting with Beverages and Condiments](https://www.ask-codey.com/lessons/TODO)

## Cheat sheets

- [GET](https://www.ask-codey.com/cheat-sheets/restful-web-apis-get-insomnia-cheat-sheet)

Source: https://www.ask-codey.com/lessons/restful-web-apis-get
