Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

REST API Integration with Feign HTTP client | AEM Community Blog Seeding

kautuk_sahni
Community Manager
Community Manager

BlogImage.jpg

REST API Integration with Feign HTTP client by Matija Kovaček

Abstract

1. Introduction
In projects we often have some integrations with API layer of 3rd party systems. This means that on our side we need to prepare HTTP client to be able consume those endpoints. Based on API specification we need to prepare Resource representation classes. Then, HTTP client with some configurations, like headers, timeouts, error handling. Parse request and response payloads into objects and many other things. All off this on the end creates a lot of boilerplate code.

Inspired with my latest project I want to introduce Feign HTTP client. Feign is HTTP client which goal is to simplify writing HTTP clients. Goal is to reduce complexity of REST API integrations.

With Feign we need to declare and annotate an interface based on API specification. And in background Feign will process annotations into a templated requests. Feign offers you to configure different HTTP clients, JSON/XML processors, metric providers, loggers and some other features.

2. Example
Throughout this article, we will integrate Faker APIs in Adobe Experience Manager (AEM) project. Goal is to get some fake generated data about users and addresses.

3. Setup
First, in your AEM project add needed dependencies.


io.github.openfeign
feign-core
11.0


io.github.openfeign
feign-jackson
11.0



com.fasterxml.jackson.core
jackson-core
2.12.0


com.fasterxml.jackson.core
jackson-annotations
2.12.0


com.fasterxml.jackson.core
jackson-databind
2.12.0

Besides the feign-core , additionaly we'll use feign-jackson for JSON processing. _ Feign-jackson _ requires jackson-core , jackson-annotations and _ jackson-databind _ dependencies.

To prevent unresolved import packages, we need to install those dependencies in Apache Felix Web console or embed them into our project bundle.

Embed dependencies in _ filevault-package-maven-plugin _ configuration.

Read Full Blog

REST API Integration with Feign HTTP client

Q&A

Please use this thread to ask the related questions.

0 Replies