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"),
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:
Kindly let me know the outcome at your earliest convenience.
Blessings,
Judith
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!
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.
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!
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.