Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Screening /
  • World-Check One /

For a deeper look into our World Check One API, look into:

Overview |  Quickstart |  Documentation |  Downloads

avatar image
Question by evanthia.tingiri · Sep 24, 2020 at 09:04 AM · world-checkworld-check-onejavaerror-401

Getting 401 Unauthorized when using Feign Framework, not when using HttpRequest Library

When trying to call the request to save a case, if I use HttpRequest Library as shown below it works fine:


HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
https://rms-world-check-one-api.thomsonreuters.com/v1/cases
    .uri(URI.create("https://rms-world-check-one-api.thomsonreuters.com/v1/cases"))
    .header("Content-Type", "application/json")
    .header("Authorization", authorisationString) //authorisationString computed in a different part of the code
    .header("Date", currentDateString)
    .POST(HttpRequest.BodyPublishers.ofString(body)) //body of the request
    .build();
HttpResponse<String> response = client.send(request,
    HttpResponse.BodyHandlers.ofString());
return content.readValue(response.body(), ResponseCase.class);


The above works fine.


However, when I try to use Feign Framework along with Spring, it gives me 401 error, even though we have been using it with these frameworks for years and we haven't changed anything in the code below:

@Configuration
public class ThomsonServiceClientConfig {

    @Bean
    public ThomsonServiceClient caseClient(ThomsonServiceContext context) {
        return Feign.builder()
            .logLevel(Logger.Level.BASIC)
            .logger(new Slf4jLogger())
            .decoder(new JacksonDecoder())
            .target(ThomsonServiceClient.class, "https://rms-world-check-one-api.thomsonreuters.com");
    }
}
public interface ThomsonServiceClient {

    @RequestLine("POST /v1/cases")
    @Headers({ "Content-Type: application/json", "Authorization: {auth}", "Date: {date}" })
    ResponseCase getCase(@Param("auth") String auth, @Param("date") String date, String requestBody); 
}

Having the above classes, when calling this:

return executor.submit(() -> thomsonServiceClient.getCase(authorisationString, currentDateString, body)).get(); //same authorisationString and currentDate as in the httpRequest snippet

It returns the following Exceptions:


Caused by: java.util.concurrent.ExecutionException: feign.FeignException$Unauthorized: [401] during [POST] to [https://rms-world-check-one-api.thomsonreuters.com/v1/cases] [ThomsonServiceClient#getCase(String,String,String)]: []

at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:na]

at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[na:na]

at com.emso.nebula.sanction.thomson.webservice.ThomsonService.getCase(ThomsonService.java:78) ~[classes/:na]

... 99 common frames omitted

Caused by: feign.FeignException$Unauthorized: [401] during [POST] to [https://rms-world-check-one-api.thomsonreuters.com/v1/cases] [ThomsonServiceClient#getCase(String,String,String)]: []

at feign.FeignException.clientErrorStatus(FeignException.java:197) ~[feign-core-10.10.1.jar:na]

at feign.FeignException.errorStatus(FeignException.java:177) ~[feign-core-10.10.1.jar:na]

at feign.FeignException.errorStatus(FeignException.java:169) ~[feign-core-10.10.1.jar:na]

at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:92) ~[feign-core-10.10.1.jar:na]


We have been calling the WC1 api using Feign and Spring for a long time now, we just started seeing these errors this week.

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

2 Replies

  • Sort: 
avatar image
Best Answer
Answer by evanthia.tingiri · Sep 24, 2020 at 10:36 PM

Thank you for replying. Turns out, we updated recently spring boot that automatically updated Feign from 10.9 to 10.10.1. This introduced a bug in Feign where it automatically appends a space next to each comma in the header values. So it was messing up the authorization token and the Date.

The bug is already reported here:

https://github.com/OpenFeign/feign/issues/1270

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Answer by Prabhjyot · Sep 24, 2020 at 12:18 PM

@evanthia.tingiri,

Thank you for your query.

Can you please share the raw request and response headers of the failed API call along with the request body?

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
13 People are following this question.

Related Questions

401 when asking for GetMyTopLevelGroups (SEQ-1a) by using Java code

Unauthorized 401 when calling /cases with POST

Hi,We are trying to perform end to end screening via SAP PO. While establishing the connectivity we are facing 401 unauthorized error.

SEQ-4a Post Screen a case get Error 401 Unauthorized

401 Unauthorized when attempting to post a case

  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • FX Venues
    • FX Trading – RFQ Maker
  • Intelligent Tagging
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open Calais
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • RDMS
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • Workspace SDK
    • Element Framework
    • Grid
  • World-Check Data File
  • Yield Book Analytics
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges