Copy of 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. 2. Setting Up the Example Let’s start by adding a simple Person model class to represent the data to be posted: public class Person… Continue Reading spring-resttemplate-post-json-test

Spring WebClient vs. RestTemplate 1. Introduction In this tutorial, we’re going to compare two of Spring’s web client implementations – RestTemplate and new Spring 5’s reactive alternative WebClient. 2. Blocking vs. Non-Blocking Client It’s a common requirement in web applications to make HTTP calls to other services. Therefore, we need… Continue Reading spring-webclient-resttemplate

Get and Post Lists of Objects with RestTemplate 1. Introduction The RestTemplate class is the central tool for performing client-side HTTP operations in Spring. It provides several utility methods for building HTTP requests and handling responses. And, since RestTemplate integrates well with Jackson, it can serialize/deserialize most objects to and from JSON… Continue Reading spring-rest-template-list

Http Message Converters with the Spring Framework 1. Overview This article describes how to Configure HttpMessageConverters in Spring. Simply put, we can use message converters to marshall and unmarshall Java Objects to and from JSON, XML, etc – over HTTP. Further reading: Spring MVC Content Negotiation A guide to configuring… Continue Reading spring-httpmessageconverter-rest

Quick Guide to @RestClientTest in Spring Boot 1. Introduction This article is a quick introduction to the @RestClientTest annotation. The new annotation helps simplify and speed up the testing of REST clients in your Spring applications. 2. REST Client Support in Spring Boot Pre-1.4 Spring Boot is a handy framework… Continue Reading restclienttest-in-spring-boot

Basic Authentication with the RestTemplate Table of Contents * 1. Overview * 2. Setting up the RestTemplate in Spring * 3. Manual management of the Authorization HTTP header * 4. Automatic management of the Authorization HTTP header * 5. Maven dependencies * 6. Conclusion 1. Overview This article shows how… Continue Reading how-to-use-resttemplate-with-basic-authentication-in-spring

RestTemplate with Digest Authentication 1. Overview This article will show how to configure the Spring RestTemplate to consume a service secured with Digest Authentication. Similar to Basic Authentication, once Digest auth is set in the template, the client will be able to go through the necessary security steps and get… Continue Reading resttemplate-digest-authentication

Download a Large File Through a Spring RestTemplate 1. Overview In this tutorial, we’re going to show different techniques on how to download large files with RestTemplate. 2. RestTemplate RestTemplate is a blocking and synchronous HTTP Client introduced in Spring 3. According to the Spring documentation, it’ll be deprecated in the future… Continue Reading spring-resttemplate-download-large-file