title: How to Get exact Rest API Error from Feign Client
body: <p>I am new to Feign Client on Spring Boot, so please permit me.</p>
  <p>I am trying to make a network call with Feign Client using the code below</p>
  <pre><code>fun validateAccessToken(accessToken: String?): ResponseEntity&lt;ObjectNode&gt; {
          val tokenConfirmationEndpoint = &quot;https://graph.facebook.com&quot;
          val facebookAPIClient = Feign
              .builder()
              .target(FacebookAPIClient::class.java, tokenConfirmationEndpoint)
          val facebookAccessTokenResponse = facebookAPIClient.validateAccessToken(accessToken)
          val body = JSONObject(facebookAccessTokenResponse?.body)
          logger.info(&quot;Feign Error $body&quot;)
          return responseHandler.errorResponse(facebookAccessTokenResponse?.statusCode?.value() ?: 0, body.toString())
      }
  </code></pre>
  <p>Now, when I deliberately supplied a wrong access Token to test the client using Post Man as below</p>
  <p>Request is <a href="http://localhost:8080/validateToken?token=adadadadad" rel="nofollow noreferrer">http://localhost:8080/validateToken?token=adadadadad</a></p>
  <p>The Facebook API is returning a valid error that states <code>Invalid OAUTH access token</code> but instead of Feign client to give me the actual error message from Facebook, Feign client is adding some text before the error message.</p>
  <p>Here is what Feign Client is returning as the error message</p>
  <pre><code>feign.FeignException$BadRequest: [400 Bad Request] during [GET] to [https://graph.facebook.com/me?access_token=adadadadad] [FacebookAPIClient#validateAccessToken(String)]: [{\&quot;error\&quot;:{\&quot;message\&quot;:\&quot;Invalid OAuth access token.\&quot;,\&quot;type\&quot;:\&quot;OAuthException\&quot;,\&quot;code\&quot;:190,\&quot;fbtrace_id\&quot;:\&quot;ApihqZcs6bOyBjCxDgTYklS\&quot;}}]\n\tat feign.FeignException.clientErrorStatus(FeignException.java:213)\n\tat feign.FeignException.errorStatus(FeignException.java:194)\n\tat feign.FeignException.errorStatus(FeignException.java:185)\n\tat feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:92)\n\tat feign.AsyncResponseHandler.handleResponse(AsyncResponseHandler.java:96)\n\tat feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138)
  </code></pre>
  <p>But I want it to instead return exactly the error from facebook as this</p>
  <pre><code>{\&quot;error\&quot;:{\&quot;message\&quot;:\&quot;Invalid OAuth access token.\&quot;,\&quot;type\&quot;:\&quot;OAuthException\&quot;,\&quot;code\&quot;:190,\&quot;fbtrace_id\&quot;:\&quot;ApihqZcs6bOyBjCxDgTYklS\&quot;}}
  </code></pre>
  <p>And nothing more.</p>
  <p>So, how can I make the Feign Client return the exact message from the API and stop adding all that FeignException text before and after the error?</p>
  <p>Thank you</p>