title: What the difference between RestTemplate x Feign Client?
body: <p>I tried to build a Spring <code>Feign Client</code> to encapsulate the call to an internal API. In this request, I need to make a login in order to get a token and then use it as a Header parameter for my new request. To set the token dynamically, I used the code below.</p>
  
  <pre><code>@FeignClient(value = "APIBuscarCep", url = "${url}")
  public interface BuscarCepFeignClient {
  
      @RequestMapping(method = RequestMethod.GET, value = "url-complement", produces = "application/json")
      @Headers({"Authorization: {token}"})
      CepResponseDTO getAddressByCep(@Param("token") String token, @NotNull @PathVariable("cep") String cep);
  }
  </code></pre>
  
  <p>Unfortunately, besides the login goes right and get token, my request always returns the <code>403 code</code>. (I used postman to check if the request should return successfully).</p>
  
  <p>The only solution that works was using <code>restTemplate</code> like the code below.</p>
  
  <pre><code>HttpHeaders headers = new HttpHeaders();
  
  headers.setContentType(MediaType.APPLICATION_JSON);
  headers.add("Authorization", token);
  ResponseEntity&lt;CepResponseDTO&gt; exchange;
  
  exchange = restTemplate.exchange(String.format("%s%s", endpoint, cep),              
                                   HttpMethod.GET, header, CepResponseDTO.class);
  </code></pre>
  
  <h3>Question</h3>
  
  <ul>
  <li>Is there any difference between the building of those classes? </li>
  <li>How can I make the request using Feign Client?</li>
  </ul>
  
  <h3>Specs</h3>
  
  <p>Using Spring boot 2.</p>