Category: REST

  • Defining projections with Jackson views, REST and Spring Boot

    Sometimes it makes sense to reuse DTOs when building REST interfaces. It is convenient as you do not need to re-implement them for every interface and it makes your API consistent as changes in the DTO will be reflected everywhere. However, you might need to send different subsets of data at different interfaces. For example,…

  • How to configure path variables in Spring controllers

    Path variables are an essential component which we use when interacting with REST APIs. In this tutorial, we will discuss what path variables are (not to be confused with query parameters) and how to use and configure them in Spring controllers. If you are just starting out with building REST APIs in Spring or Spring…

  • How to configure query parameters in Spring Controllers

    In this post, we will discuss what query parameters are and how to configure them in a Spring controller using the @RequestParam annotation. We will also discuss how to set your query parameters as optional, how to configure multiple query parameters and more. Before we start, I highly recommend that you check out our introductory…

  • Error handling in REST and Spring Boot

    In our previous tutorials, we discussed how build a CRUD REST API in a Spring Boot environment. However, we have not yet discussed how to handle common errors that can occur, such as when the user tries to fetch a non-existing item. In this tutorial, we will discuss some solutions and strategies for handling errors…

  • Using PUT vs PATCH when building a REST API in Spring

    In our previous post “how to create a CRUD REST API in Spring Boot”, we discussed how to create a basic REST interface in Spring boot using the different HTTP verb mapping annotations @GetMapping, @DeleteMapping, @PutMapping and @PostMapping. These mappings correspond to the HTTP methods GET, DELETE, PUT and POST respectively. However, we have not…

  • How to validate REST calls in Spring Boot

    In our previous post, we discussed how to get started with REST in Spring boot, and how to get a REST endpoint up and running. However, callers of the endpoint were able to send any data to our server, and this data would be accepted and saved by our server without any sort of checks…

  • How to create a CRUD REST API in Spring Boot

    REST APIs are a very important layer in many Spring applications. Specially if you need to provide interfaces for other services in your ecosystem such as front-end applications or to external systems, such as customer systems. In this post, we will discuss how to start building your REST API using Spring Boot in order to…