Exploring the Spring Boot TestRestTemplate 1. Overview This article explores the Spring Boot TestRestTemplate. It can be treated as a follow-up of The Guide to RestTemplate, which we firmly recommend to read before focusing on TestRestTemplate. TestRestTemplate can be considered as an attractive alternative of RestTemplate. 2. Maven Dependencies To… Continue Reading spring-boot-testresttemplate

RestTemplate Post Request with JSON 1. Introduction In this tutorial, we’ll illustrate how to use Spring’s RestTemplate to make POST requests sending JSON content. Further reading: Exploring the Spring Boot TestRestTemplate Learn how to use the new TestRestTemplate in Spring Boot to test a simple API. Read more → Spring… Continue Reading spring-resttemplate-post-json

Uploading MultipartFile with Spring RestTemplate 1. Overview This quick tutorial focuses on how to upload a multipart file using Spring’s RestTemplate. We’ll see both a single file and multiple files – upload using the RestTemplate. 2. What is an HTTP Multipart Request? Simply put, a basic HTTP POST request body holds… Continue Reading spring-rest-template-multipart-upload

Authentication Against a REST Service with Spring Security REST Spring Security Authentication RestTemplate Table of Contents 1. Overview 2. The Goal 3. The Client 4. Testing the Authentication Service 5. Conclusion 1. Overview This article is focused on how to authenticate against a secure REST API that provides a RESTful… Continue Reading authentication-against-a-third-party-service

Configure a RestTemplate with RestTemplateBuilder 1. Introduction In this quick tutorial, we’re going to look at how to configure a Spring RestTemplate bean. Let’s start by discussing the three main configuration types: using the default RestTemplateBuilder using a RestTemplateCustomizer creating our own RestTemplateBuilder To be able to test this easily, please follow… Continue Reading spring-rest-template-builder

Spring RestTemplate Error Handling 1. Overview In this short tutorial, we’ll discuss how to implement and inject the ResponseErrorHandler interface in a RestTemplate instance – to gracefully handle HTTP errors returned by remote APIs.  2. Default Error Handling By default, the RestTemplate will throw one of these exceptions in case of… Continue Reading spring-rest-template-error-handling

Authenticating with Reddit OAuth2 and Spring Security 1. Overview In this tutorial, we’ll use Spring Security OAuth to authenticate with the Reddit API. 2. Maven Configuration First, in order to use Spring Security OAuth – we need to add the following dependency to our pom.xml (of course along any other… Continue Reading spring-security-oauth2-authentication-with-reddit

StackExchange REST Client with Spring and RestTemplate HTTP Client-Side Spring Web HttpClient RestTemplate This article will cover a quick side-project – a bot to automatically tweet Top Questions from the various Q&A StackExchange sites, such as StackOverflow, ServerFault, SuperUser, etc. We will build a simple client for the StackExchange API… Continue Reading tweeting-stackexchange-with-spring-social-part-1