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 wangguoqing · Jul 24, 2019 at 06:32 AM · world-checkworld-check-oneerror-401

I have a problem accessing the World-check-one API. Please help me. The same request parameter, in which the name parameter is Chinese, returns 401 Unauthorized, the name can be changed to English after the normal request.

您好,我在访问World-check-one API时遇到问题。请帮我。name参数为Chinese的相同请求参数返回401 Unauthorized,正常请求后名称可以更改为英文。以下是DEMO根据您的官方API实施的测试类

postrequest.txt

// A simple request to create a Case using Http Post public static void main(String[] args) throws Exception { CloseableHttpClient httpclient = HttpClients.createDefault(); try { Date now = new Date();

//format for date string Mon, 27 Mar 2017 15:19:36 GMT DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z",Locale.ENGLISH); df.setTimeZone(TimeZone.getTimeZone("GMT"));

String date = df.format(now); String gatewayurl = "/v1/"; String gatewayhost = "rms-world-check-one-api-pilot.thomsonreuters.com"; String apikey = "xxxxx"; String apisecret = "xxx"; String groupid = "0a3687d0-6a26-186f-9a9b-af9100000a4b"; //create a JSON string String jsonBody = "{\"secondaryFields\":[{\"typeId\":\"SFCT_1\",\"value\":\"FEMALE\"},{\"dateTimeValue\":\"1946-09-14\",\"typeId\":\"SFCT_2\"},{\"typeId\":\"SFCT_5\",\"value\":\"CHN\"}],\"entityType\":\"INDIVIDUAL\",\"groupId\":\"0a3687d0-6a26-186f-9a9b-af9100000a4b\",\"providerTypes\":[\"WATCHLIST\"],\"name\":\"杨秀珠\"}";

// create a JSON object from the JSON string JSONObject jo = new JSONObject(jsonBody); //System.out.println(jo.toString()); String jlen = String.valueOf(jo.toString().length()); String dataToSign = "(request-target): post " + gatewayurl + "cases/screeningRequest\n" + "host: " + gatewayhost + "\n" + "date: " + date + "\n" + "content-type: " + "application/json" +"\n" + "content-length: " + jlen + "\n" + jo; String hmac = generateAuthHeader(dataToSign, apisecret); String authorisation = "Signature keyId=\"" + apikey + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date content-type content-length\",signature=\"" + hmac + "\""; System.out.println(jlen); System.out.println(dataToSign); //System.out.println(hmac); System.out.println(authorisation); String msg = jsonBody.toString();

HttpPost httpPost = new HttpPost("https://rms-world-check-one-api-pilot.thomsonreuters.com/v1/cases/screeningRequest"); HttpEntity entity = new StringEntity(msg); httpPost.setEntity(entity); httpPost.addHeader("Date", date); httpPost.addHeader("Cache-Control", "no-cache"); httpPost.addHeader("Content-Type", "application/json" ); httpPost.addHeader("Authorization", authorisation); // send the POST request CloseableHttpResponse response1 = httpclient.execute(httpPost); try { HttpEntity entity1 = response1.getEntity(); System.out.println(response1.getStatusLine()); String json = EntityUtils.toString(response1.getEntity()); //System.out.println(entity1); // json string returned System.out.println(json); ObjectMapper mapper = new ObjectMapper(); // printout in Pretty format Object jsonObj = mapper.readValue(json, Object.class); String indented = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObj); System.out.println(indented); EntityUtils.consume(entity1); } finally { response1.close(); } } finally { httpclient.close(); } }

postrequest.txt (5.0 KiB)

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.

7 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by Chris.Lee1 · Jul 24, 2019 at 11:28 PM

Hi @wangguoqing,

please reference below:

function generateAuthHeader(dataToSign){ var hash = CryptoJS.HmacSHA256(dataToSign,environment["api-secret"]); return hash.toString(CryptoJS.enc.Base64); } function isEnvValuePopulated(envVal) { if (_.isEmpty(pm.environment.get(envVal))) { pm.environment.set(envVal, "--REQUIRED-VALUE-MISSING--"); return false; } else { return true; } } isEnvValuePopulated("group-id"); var date = new Date().toGMTString(); var content = request.data; content = content.replace("{ {group-id}}", environment["group-id"]); var contentLength = unescape(encodeURIComponent(content)).length; var dataToSign = "(request-target): post " + environment["gateway-url"] + "cases\n" + "host: " + environment["gateway-host"] + "\n" + "date: " + date + "\n" + "content-type: " + environment["content"] +"\n" + "content-length: " + contentLength + "\n" + content; var hmac = generateAuthHeader(dataToSign); var authorisation = "Signature keyId=\"" + environment["api-key"] + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date content-type content-length\",signature=\"" + hmac + "\""; postman.setEnvironmentVariable("authorisation",authorisation); postman.setEnvironmentVariable("currentDate",date); postman.setEnvironmentVariable("contentLength",contentLength);

Comment
Prabhjyot

People who like this

1 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 · Jul 24, 2019 at 07:57 AM

@wangguoqing,

Thank you for your query.

Can you please let us know if you are enconding the request payload with UTF-8 encoding? If not, please use UTF-8 encoding for the request body. After the UTF-8 encoding, you should not get Error 401 for foreign character.

If you face the issue after UTF-8 encoding, please share the request and the response headers of the failed request along with the request body to investigate further.

Hope this helps.

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
Answer by wangguoqing · Jul 24, 2019 at 08:14 AM

Hi Prabhjyot.Mandla Hello, I've tried UTF-8 encoding for requests, but I still can't. Can you fill in what you think is the correct code in the Java sample given above?

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
Answer by wangguoqing · Jul 24, 2019 at 08:18 AM

utf-8-process.png


utf-8-process.png (96.9 KiB)
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
Answer by wangguoqing · Jul 24, 2019 at 08:25 AM

Hi Prabhjyot.Mandla Can you provide an example of World Check One API Java code that can use Chinese names as request parameters?

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 · Jul 24, 2019 at 08:32 AM

@wangguoqing,

Can you please refer to this link?

Do let us know if this helps.

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
Answer by wangguoqing · Jul 24, 2019 at 09:48 PM

Hi Prabhjyot.Mandla Thanks a lo. I'll try.

Comment
Prabhjyot

People who like this

1 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 >
10 People are following this question.

Related Questions

Save a case with Russian characters get error message : HTTP/1.1 401 Unauthorized

All calls are failing with 401 Unauthorized on Postman - Pilot environment

Hey guys , i am getting response 401 ,my code is from http.client import HTTPSConnection from base64 import b64encode #This sets up the https conn response = requests.post(url, auth=requests.auth.HTTPBasicAuth( '****', '****')) #print(response.text)

Error 401 - Groups (Working in Postman but neither in Vue Js neither in Php)

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

  • 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
  • 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
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges