Unauthorized error encountered when using cases/"+ caseId + "?aggregatedSummary=true in httpClient

Hi team,

I have a requirement to fetch case details by case ID. Initially, I successfully received a response using cases/{caseId} via C# httpClient. However, I also require the aggregated summary. According to the documentation and Postman collection, I attempted to pass cases/"+ caseId + "?aggregatedSummary=true, but encountered an Unauthorized error.

Here is the code I've been using.

DateTime dateValue = DateTime.UtcNow;
string date = dateValue.ToString("R");
string gatewayurl = "/v2/";
string gatewayhost = "api-worldcheck.refinitiv.com";
string apikey = "api-key";
string apisecret = "secret-key";
string requestendpoint = "https://api-worldcheck.refinitiv.com/v2/cases/"+ caseId + "?aggregatedSummary=true";
string signUrl = "cases/" + caseId + "?aggregatedSummary=true";

string dataToSign = "(request-target): get " + gatewayurl + signUrl + "\n" +
"host: " + gatewayhost + "\n" +
"date: " + date;

string hmac = generateAuthHeader(dataToSign, apisecret);

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

var client = new HttpClient();
var request = new HttpRequestMessage
{

Method = HttpMethod.Get,
RequestUri = new Uri(requestendpoint),
Headers =
{

{ "Authorization",authorisation },
{ "Date", date },
},
};
using (var response = await client.SendAsync(request))
{

response.EnsureSuccessStatusCode();
Console.WriteLine(response.StatusCode);
}

Can you help me find a solution?




Best Answer

  • Hi @mahesh.s ,

    Thanks for reaching out to us!

    After reviewing the above provided C# code sample, could you please update your code by omitting the query parameter("?aggregatedSummary=true") from the "signUrl" string and then pass the value in the "dataToSign" string as below.

    string signUrl = "cases/" + caseSystemId;

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


    Please feel free to reach out to us if you still face any issue after making the above changes in your code.


    Thanks

    Sai.

Answers

  • Hello @mahesh.s - thank you for reaching out to us!

    Let me gather some more information regarding your inquiry and I will get back to you as soon as I have more information. Thank you for your patience.

    Best,

    Judith

  • The code above was successful. Thank you.