Screening a case Results 401 unauthorised

Hi,
i am screening a case after creating in WCO portal with my console application. few times i am able to screen but most of the times it results in unauthorised exception.}
in my code i haven't added the content length as header. but still i am gettng the error.
could you please help me out in this.
Best Answer
-
401 errors is because the request has failed an authorisation check. This can happen for a variety of reasons, such as an invalid or expired API key, an invalid HMAC signature or a request timing issue/problem with the Date header value. The API client should ensure a correctly synchronised clock is used to generate request timestamps.
Request you to kindly provide us the request and the response headers for the failed request so that I can investigate this. Kindly mask or remove the API key before posting the requested info.
Also, can you kindly check if the HMAC generated is correct.
Kindly note the value of the dataToSign variable should be in the below format:
(request-target): get /v1/cases/0a3687d0-65b4-1321-999a-06c800262e8a/results
host: rms-world-check-one-api-pilot.thomsonreuters.com
date: Fri, 12 Oct 2018 11:50:34 GMTHere, 0a3687d0-65b4-1321-999a-06c800262e8a is the case system Id.
Also, the auth headers should be in the below format.
Authorization': "Signature keyId="XXX{{API-KEY}}XXXXXX",algorithm="hmac-sha256",headers="(request-target) host date",signature="aOmw1AJNPd1Px0nHsT/wcLoVvHL9eXhWeIP9bpz33RU="
0
Answers
-
Hi @Irfan.Khan
I am using the datatosign asvar dataToSign = "(request-target): post " + GlobalProperties.GateWayUrl + "cases/" + CaseSystemId + "/screeningRequest\n" +"host: " + GlobalProperties.GatewayHost + "\n" +"date: " + dateValue.ToString("R"); accordingly in postman application
whereas the quthorosation header isvar authorisation = "Signature keyId=\"" + GlobalProperties.APIKey + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"" + hmac + "\"";
kindly help me in this.as I am following the headers in postman application.0 -
Can you send me the response header and request header of the failed request so that I can have a look at it?
Also, can you check the time stamp on both the response header and the request header to know if they are in sync.
0 -
@Irfan.Khan
here I ama providing the code I have used in my application which was failing.
Request and Response Headers for screening a casevar dataToSign = "(request-target): post " + GlobalProperties.GateWayUrl + "cases/" + CaseSystemId + "/screeningRequest\n" +
"host: " + GlobalProperties.GatewayHost + "\n" +
"date: " + dateValue.ToString("R");
DateTime dateValue = DateTime.UtcNow;
string authorisation = "";
string hmac = generateAuthHeader(datatoSign, GlobalProperties.APISecret);
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(reqEndPoint);
WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
using (WebReq as IDisposable)
{
WebReq.Method = "POST";
WebReq.Headers.Add("Cache-Control", "no-cache");
WebReq.Date = dateValue;
authorisation = "Signature keyId=\"" + GlobalProperties.APIKey + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"" + hmac + "\"";
WebReq.Headers.Add("Authorization", authorisation);
}
try
{
using (HttpWebResponse response = (HttpWebResponse)WebReq.GetResponse())
{
using (Stream answer = response.GetResponseStream())
{
StreamReader _Answer = new StreamReader(answer);
dynamic responseData = Newtonsoft.Json.JsonConvert.DeserializeObject(_Answer.ReadToEnd());
answer.Dispose(); answer.Close();
response.Dispose(); response.Close();
return responseData;}
}
}
catch (WebException e)
{
FileHelper.Logger(FileHelper.LogType.ERROR, e.Message, "WCO_");
FileHelper.Logger(FileHelper.LogType.ERROR, e.StackTrace, "WCO_");
if (e.Status == WebExceptionStatus.Timeout)
{
// Handle timeout exception
}
else
{
}
}0 -
I would need the actual response headers received and the request headers sent to see if the request is being sent correctly.
In the mean time, I would check if the code provided is correct.
0 -
I have checked the code and it appears to be correct.
This can be a time stamp mismatch issue?
Can you compare the date header value being sent and the date header value being received(as a response header)?
Also, please log the request headers being sent and the response headers being received for the failed call and send it to me for investigation.
0 -
Following up to see if the issue still persists.
Kindly provide me the actual logged response header being received and the request header being sent to the WC1 server so that I can assist you.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 690 Datastream
- 1.5K DSS
- 629 Eikon COM
- 5.2K Eikon Data APIs
- 11 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 255 ETA
- 560 WebSocket API
- 39 FX Venues
- 15 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 25 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 281 Open PermID
- 46 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 2K Refinitiv Data Platform
- 724 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 106 UPA
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 95 Workspace SDK
- 11 Element Framework
- 5 Grid
- 19 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛