World check Api: problem with QUERY PARAMETERS

Best Answer

  • 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

Answers

  • 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);

  • 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

  • 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

  • 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

  • Understood, thanks for the specification!
  • 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"

  • with your c# example now it works.

    Thank you

  • It works. Thank's

  • That's great! Thanks for the update.


    Blessings,

    Judith