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

Overview |  Quickstart |  Documentation |  Downloads

question

Upvotes
Accepted
24 1 2 4

C# code post create-a-case returns 401 unauthorized

Hi,

I use the sample c# code, adding the api key and api secret. Call the get groups to get group id. Then call post cases to create a case with group id from previous call. This returns 401 unauthorized.

I use the same request body in postman and it works.

I notice some differences between postman and c# code. Postman has longer content length(171) than c# code generated(138) request. I don't know why.

Here is the request data from c# code

dataToSign = "(request-target): post/v2/cases\nhost: api-worldcheck.refinitiv.com\ndate: Fri, 09 Jul 2021 22:38:46 GMT\ncontent-type: application/json\ncontent-length: 138\n{\"entityType\":\"ORGANISATION\",\"groupId\":\"xxxxxxxxxxxxxxxxxxxxxxxxx\",\"provideTypes\":[\"WATCHLIST\"],\"name\":\"Lajnat ul Masa Eidatul Afghaniab\"}"

authorisation = "Signature keyId=\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date content-type content-length\",signature=\"vf7X29JltDSWMW938DwfnC6qW7A8XKrjCGHdDkczW9Y=\""

Please assist.

Thank you,

Cady

world-checkworld-check-onecase
icon clock
10 |1500

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

Upvotes
Accepted
24 1 2 4

Thanks to Prabhjyot's help, I was able to find out the typo in the request body. I had provideType. It should be providerType.

icon clock
10 |1500

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

Upvotes
548 1 1 1

@cadyh ,

Can you please share the request payload as it is being passed using the code and postman to compare the values?


icon clock
10 |1500

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

Upvotes
24 1 2 4

The request using the code is in the question.

Here is the request using Postman



Request Headers

Date: Mon, 12 Jul 2021 13:11:34 GMTContent-Type: application/jsonAuthorization: Signature keyId="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",algorithm="hmac-sha256",headers="(request-target) host date content-type content-length",signature="8WaJl5RGH88c7zJJ7Ls5/1mexev6K35MurIZnI0sEKo="Content-Length: 171User-Agent: PostmanRuntime/7.28.1Accept: */*Cache-Control: no-cachePostman-Token: 92636f9a-73f8-4d51-b8c0-a0fee5ea9d53Host: api-worldcheck.refinitiv.comAccept-Encoding: gzip, deflate, brConnection: keep-alive

Request Body

{ "entityType": "ORGANISATION", "groupId": "xxxxxxxxxxxxxxxxxxxxxxxxx", "providerTypes": [ "WATCHLIST" ], "name": "Lajnat ul Masa Eidatul Afghaniab" }


icon clock
10 |1500

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

Upvotes
548 1 1 1

@cadyh ,

Thanks for the details.

Can you please confirm if you are using the same format as above of the request payload in the code and postman? Or are the formats getting changed in anyway?

icon clock
10 |1500

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

Upvotes
24 1 2 4

No, the format is not changed. They are both from WorldCheck sample code. The have changedthe name and added this code "ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;" from answer in other question to solve the problem with the error "Could not create secured channel". I have tried with different names.

I noticed there is a space between post and gatewayurl that I removed somehow( must be when I tried different things to solve this problem) in the dataToSign variable. I added back in. This is now the same as the sample code (below)

UTF8Encoding encoding = new UTF8Encoding();

byte[] byte1 = encoding.GetBytes(postData);

string msg = postData;

string dataToSign = "(request-target): post " + gatewayurl + "cases\n" +

"host: " + gatewayhost + "\n" + // no https only the host name

"date: " + date + "\n" + // GMT date as a string

"content-type: " + "application/json" + "\n" +

"content-length: " + byte1.Length + "\n" +

msg;


I now get a different error. With the space back in I now get error 500 Internal Server Error.

This is the dataToSign value: "(request-target): post /v2/cases\nhost: api-worldcheck.refinitiv.com\ndate: Tue, 13 Jul 2021 20:54:17 GMT\ncontent-type: application/json\ncontent-length: 138\n{\"entityType\":\"ORGANISATION\",\"groupId\":\"xxxxxxxxxxxxxxxxxxxxxxx\",\"provideTypes\":[\"WATCHLIST\"],\"name\":\"Lajnat ul Masa Eidatul Afghaniab\"}"

I see the postman body has new line and indented so I removed them all. The content length from postman is now show 139, it is 1 longer than the content length from C# code. I can't find where that 1 different in length is. Is it really the cause of the issue?

Request HeadersDate: Tue, 13 Jul 2021 20:51:43 GMTContent-Type: application/jsonAuthorization: Signature keyId="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",algorithm="hmac-sha256",headers="(request-target) host date content-type content-length",signature="e/Sxhitb/KbbSdt3Qqml0KsPbIGMLR0XwzWT6eCm5Cs="Content-Length: 139User-Agent: PostmanRuntime/7.28.1Accept: */*Cache-Control: no-cachePostman-Token: 4a30df6a-6450-400c-afa7-65210b4a92eaHost: api-worldcheck.refinitiv.comAccept-Encoding: gzip, deflate, brConnection: keep-alive


icon clock
10 |1500

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

Upvotes
4.5k 4 7 8

@cadyh ,

I will send you an email, so we can get on a call to look further into the issue.


icon clock
10 |1500

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

Click below to post an Idea Post Idea