question

Upvotes
Accepted
1 0 1 1

World check Api: problem with QUERY PARAMETERS

With c# in every Api with query parameters i have error 401.

Example:

this works:

RequestUri = new Uri("https://api-worldcheck.refinitiv.com/v2/cases/5jb6uu6extle1hugpq6ibcm37),

error 401:

RequestUri = new Uri("https://api-worldcheck.refinitiv.com/v2/cases/5jb6uu6extle1hugpq6ibcm37?aggregatedSummary=true"),
#productc#worldcheck-one-apipilot-environment
icon clock
10 |1500

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

Upvotes
Accepted
1.2k 2 2 3

Hi @raffaele.rocco, I have emailed you a working request sample with the query parameters "?aggregatesSummary=true". Kindly take a look at it at your earliest convenience.
A couple things to note:

  • With the attached sample code, we can confirm that the provided case system id has returned an aggregated summary of the case against the API key and API secret
  • To confirm a successful API response with the end point "?aggregatedSummary=true", we advise to wrap the end point as a URI instead of sending it as a string. The attached sample code does contain such code line
  • The sample code contains your API credentials included the case system id. Please import the sample code as a project with your IDE. The project name is api.sln
  • The sample code contains an Authorization builder to takes care of generating the hmac. The authorization builder is contained in the code file name AuthHeaderBuilder.cs. This is part of the project.

Kindly let me know the outcome at your earliest convenience.

Blessings,

Judith

icon clock
10 |1500

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

with your c# example now it works.

Thank you

Upvotes
1 0 1 1

Complete code from your example:


DateTime dateValue = DateTime.UtcNow;


string date = dateValue.ToString("R");


string gatewayurl = "/v2/";

string gatewayhost = "api-worldcheck.refinitiv.com";


string apikey = "xxxxxxxxxxxxxxxxxxxx";


// "caseId": "5jb6uu6extle1hugpq6ibcm36",

string apisecret = "xxxxxxxxxxxxxxxxxx";

string nameApi = "cases/5jb6uu6extle1hugpq6ibcm37";

//error 401

//string nameApi = "cases/5jb6uu6extle1hugpq6ibcm37?aggregatesSummary=true";

string requestendpoint = "https://api-worldcheck.refinitiv.com/v2/" + nameApi;


string dataToSign = "(request-target): get " + gatewayurl + nameApi + "\n" +

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

"date: " + date; // GMT date as a string

// The Request and API secret are now combined and encrypted

string hmac = generateAuthHeader(dataToSign, apisecret);


string authorisation = "Signature keyId=\"" + apikey + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"" + hmac + "\"";


Console.WriteLine(authorisation);

// Send the Request to the API server

HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(requestendpoint);

// Set the Headers

WebReq.Method = "GET";

WebReq.Headers.Add("Authorization", authorisation);

WebReq.Headers.Add("Cache-Control", "no-cache");

WebReq.Date = dateValue; // use datetime value GMT time


// Get the Response - Status OK

HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();

// Status information about the request

Console.WriteLine(WebResp.StatusCode);

Console.WriteLine(WebResp.ResponseUri);


// Get the Response data

Stream Answer = WebResp.GetResponseStream();

StreamReader _Answer = new StreamReader(Answer);

string jsontxt = _Answer.ReadToEnd();


// convert json text to a pretty printout

var obj = Newtonsoft.Json.JsonConvert.DeserializeObject(jsontxt);

var f = Newtonsoft.Json.JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented);

Console.WriteLine(f);

icon clock
10 |1500

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

Upvotes
1.2k 2 2 3

Hello @raffaele.rocco - thank you for reaching out. I will be looking into your question shortly and will respond to you as soon as I have an update. Thanks!

Blessings,

Judith

icon clock
10 |1500

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

Ok thank's.

If it can help you, i have error only when i use this format to the url:

?param=xxxx

instead it works in this format:

/param

Understood, thanks for the specification!
Upvotes
1.2k 2 2 3

Hi @raffaele.rocco - thank you for your patience. Our World-Check One API Dev Community Downloads section has Request Code Samples, and I am attaching our updated C# .NET samples below: postRequest.txt & getRequest.txt

Kindly let me know if these request samples are able to help you get a successful response at your earliest convenience.

Blessings,

Judith


postrequest.txt (5.8 KiB)
getrequest.txt (4.4 KiB)
icon clock
10 |1500

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

Sorry Judith, but your example is the same one i used and it works.

I have the error 401 only when i use query parameters!

Example:

string requestendpoint = "https://api-worldcheck.refinitiv.com/v2/cases/5jb6uu6extle1hugpq6ibcm37?aggregatesSummary=true"

Upvotes
1 0 1 1

It works. Thank's

icon clock
10 |1500

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

That's great! Thanks for the update.


Blessings,

Judith

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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