<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mrigendra Kumar on Medium]]></title>
        <description><![CDATA[Stories by Mrigendra Kumar on Medium]]></description>
        <link>https://medium.com/@mrigendra10114005?source=rss-2110cb940489------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SHBcjV990N4UvZaVGjD8lQ.jpeg</url>
            <title>Stories by Mrigendra Kumar on Medium</title>
            <link>https://medium.com/@mrigendra10114005?source=rss-2110cb940489------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 19:29:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mrigendra10114005/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[INTEGRATING THIRD PARTY API’s IN SPRING BOOT USING FEIGN CLIENT]]></title>
            <link>https://medium.com/@mrigendra10114005/integrating-third-party-apis-in-spring-boot-using-feign-client-fe8018e3bb97?source=rss-2110cb940489------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe8018e3bb97</guid>
            <dc:creator><![CDATA[Mrigendra Kumar]]></dc:creator>
            <pubDate>Sat, 23 May 2020 17:30:30 GMT</pubDate>
            <atom:updated>2020-05-23T17:30:30.841Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>1. What is feign client?</strong></p><p>Feign is an abstraction over REST-based calls, by which microservices can communicate with each other, but developers don’t have to bother about REST internal details.</p><p><strong>2.</strong> <strong>Why are we going to use feign client over other client of spring boot?</strong></p><p>Suppose we are using a normal http client for making a third party api call, In that case you have to take care of all the stuff like first you have to handle https response, which you will get after the API’s call . After getting a response from the server you have to extract the object of desired type. But in case of feign you will directly get your desired object in third party api call.</p><p><strong>3. Needed dependency for feign client in spring boot gradle.</strong></p><pre>File name: - build.gradle<br>        ext {<br>        set(&quot;feignVersion&quot;, &quot;10.2.0&quot;)<br>        }<br><br>        dependencies{<br>        implementation(&quot;org.springframework.cloud:spring-cloud-starter-openfeign&quot;)<br>        implementation(&quot;io.github.openfeign:feign-httpclient:$feignVersion&quot;)<br>        }</pre><p><strong>4.Implementation of feign client</strong></p><ul><li>We are going to create a small POC for implementation of feign .</li><li>Suppose we are going to design a college website.</li><li>On this website suppose there are two servers, one for library and other for rest.</li><li>Suppose a student wants to see all books corresponding to java.</li><li>There are API’s which are exposed by the library by which we can get a list of books for a particular type.</li></ul><p>In this poc we are going to integrate library api through feign client</p><p>Contract of library’s Api for getting list of book:</p><p><strong>{</strong></p><p><strong>methodType : POST</strong></p><p><strong>BaseUrl : iiit_kalyani/list_of_book</strong></p><p><strong>endPoint : </strong><a href="https://ufp-user.php-main-dev.pharmeasy.in/"><strong>https://user.java-main-dev.iiitkalyani.in/</strong></a></p><p><strong>authToken(option) : &lt;authtoken&gt;</strong></p><p><strong>}</strong></p><p>We are going to create a proxy file for calling the library’s api using feign client.</p><p>File name:- GetBookDetailsProxy.java</p><pre>import feign.Headers;<br>import org.springframework.cloud.openfeign.FeignClient;<br>import org.springframework.http.HttpHeaders;<br>import org.springframework.web.bind.annotation.PostMapping;<br>import org.springframework.web.bind.annotation.RequestBody;<br>import org.springframework.web.bind.annotation.RequestHeader;<br><br>@FeignClient(name = &quot;library-proxy&quot;, url = &quot; https://user.java-main-dev.iiitkalyani.in/&quot;)<br>interface GetBookDetailProxy {<br><br>    @PostMapping(value = &quot; iiit_kalyani/list_of_book&quot;)<br>    @Headers(&quot;Content-Type: application/json&quot;)<br>    PsCreateOnlinePaymentOrderResponse createOnlinePaymentOrder(<br>            ResponseBody GetOnlineListOfBook( @RequestBody RequestBody request );<br><br>    );<br><br>}</pre><p>we are going to call proxy for getting the list of books</p><pre>public class ResponseBody(String topicName) {<br>        if (topicName == null) {<br>        log.info(&quot;topicName cannot be null for get list of book&quot;);<br>        throw new GatewayException(messageSource);<br>        }<br>        RequestBody requestBody = new RequestBody(topicName);<br>        try {<br>        ResponseBody listOfBook =     GetBookDetailProxy.GetOnlineListOfBook(<br>        requestBody<br>        );<br>        } catch (FeignException fe) {<br>        log.error(&quot;Exception while calling library api&quot; + fe);<br>        throw new GatewayException(messageSource);<br>        }<br>        return listOfBook;<br>        }</pre><p>request pojo for getting list of books</p><p>file name: RequestBody.java</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*G80jb1-5-SE4jX98KDIgew.png" /></figure><p>response pojo for getting list of books</p><p>file name:- ResponseBody.java</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*-LK_RkcQBUkyi1e7t_imeA.png" /></figure><p>In next article we will discuss , how exception handling gets easier by using feign client.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe8018e3bb97" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>