#Another RestTemplate Mystery

7 messages · Page 1 of 1 (latest)

open condor
#

Why is this GET request returning a 401 UNAUTHORIZED when I try to make the call from my application, but the exact same request is successful in Postman?

2023-06-26 19:45:42,243 [http-nio-5672-exec-5] INFO  c.h.i.RequestResponseHttpLoggingInterceptor:31 - ===========================request begin================================================
2023-06-26 19:45:42,244 [http-nio-5672-exec-5] INFO  c.h.i.RequestResponseHttpLoggingInterceptor:32 - URI         : http://localhost:64155/services/gdsservice/data/reservation/select?pnr=AKLTYN
2023-06-26 19:45:42,244 [http-nio-5672-exec-5] INFO  c.h.i.RequestResponseHttpLoggingInterceptor:33 - Method      : GET
2023-06-26 19:45:42,244 [http-nio-5672-exec-5] INFO  c.h.i.RequestResponseHttpLoggingInterceptor:34 - Headers     : [Accept:"application/json, application/*+json", Content-Type:"application/json", Authorization:"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJjdHJhY3lAc3dpZnR0cmlwLmNvbSIsImV4cCI6MTY4Nzg0MTE0MiwiaWF0IjoxNjg3ODIzMTQyfQ.KJPJslidN3suikyaQ94e54zgKTd59MuZpyCDHczdGz_l2gXAqkxUILGtQVwxv1JPFgblPFK_w6eXy_3eJzWvLA", Content-Length:"0"]
2023-06-26 19:45:42,244 [http-nio-5672-exec-5] INFO  c.h.i.RequestResponseHttpLoggingInterceptor:36 - Request body: 
2023-06-26 19:45:42,245 [http-nio-5672-exec-5] INFO  c.h.i.RequestResponseHttpLoggingInterceptor:38 - ==========================request end================================================
2023-06-26 19:45:42,248 [http-nio-5672-exec-5] INFO  c.h.i.RequestResponseHttpLoggingInterceptor:42 - ============================response begin==========================================
2023-06-26 19:45:42,249 [http-nio-5672-exec-5] INFO  c.h.i.RequestResponseHttpLoggingInterceptor:43 - Status code  : 401 UNAUTHORIZED
2023-06-26 19:45:42,249 [http-nio-5672-exec-5] INFO  c.h.i.RequestResponseHttpLoggingInterceptor:44 - Status text  : 
2023-06-26 19:45:42,250 [http-nio-5672-exec-5] INFO  c.h.i.RequestResponseHttpLoggingInterceptor:45 - Headers      : [Vary:"Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers", WWW-Authenticate:"Basic realm="Realm"", X-Content-Type-Options:"nosniff", X-XSS-Protection:"1; mode=block", Cache-Control:"no-cache, no-store, max-age=0, must-revalidate", Pragma:"no-cache", Expires:"0", X-Frame-Options:"DENY", Content-Type:"application/json", Transfer-Encoding:"chunked", Date:"Mon, 26 Jun 2023 23:45:42 GMT", Keep-Alive:"timeout=60", Connection:"keep-alive"]
2023-06-26 19:45:42,251 [http-nio-5672-exec-5] INFO  c.h.i.RequestResponseHttpLoggingInterceptor:51 - Response body: {"timestamp":1687823142247,"status":401,"error":"Unauthorized","message":"Unauthorized","path":"/services/gdsservice/data/reservation/select"}
2023-06-26 19:45:42,251 [http-nio-5672-exec-5] INFO  c.h.i.RequestResponseHttpLoggingInterceptor:53 - =======================response end=================================================```
empty beaconBOT
#

This post has been reserved for your question.

Hey @open condor! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

empty beaconBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

tribal wind
#

@open condor you need to pre-append Bearer <token>

#

in your authorization header

empty beaconBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.