...' (400) Errors
Hi Team,
I'm facing an issue when consuming the resolution API. Despite providing all the inputs according to the API documentation, I'm consistently receiving a "NOT FOUND" (404) error at the code level. Interestingly, when I attempt the same API call in POSTMAN, it throws a 400 error.
I've attached a sample of the code used and a screenshot of the POSTMAN error for your reference.
try
{
DateTime dateValue = DateTime.UtcNow;
string date = dateValue.ToString("R");
string apikey = "api-key";
string apisecret = "api-secret";
string gatewayurl = "/v2/";
string gatewayhost = "api-worldcheck.refinitiv.com";
string caseid = "5jb8f4kwwiid1io3p60279iql";
string requestendpoint = "https://api-worldcheck.refinitiv.com/v2/cases/"+ caseid + "/results/resolution";
string statusid = "5jb6u6iwkglj1i8ffosan21p5"; // took this value from groups/{{group-id}}/resolutionToolkit - statuses
string riskId = "5jb6u6iwkglj1i8ffosan21os"; // took this value from groups/{{group-id}}/resolutionToolkit - risks
string reasonId = "5jb6u6iwkglj1i8ffosan21op"; // took this value from groups/{{group-id}}/resolutionToolkit - reasons
string resolutionRemark = "test resolution";
string resultIds = "5jb7l7a1ekas1io3p6216axn8";
string signUrl = "cases/" + caseid + "/results/resolution";
string postData = "{\"statusId\":\""+ statusid + "\",\"riskId\":\""+ riskId + "\",\"reasonId\":\""+ reasonId + "\",\"resolutionRemark\":\""+ resolutionRemark + "\",\"resultIds\":[\""+ resultIds + "\"]}";
string msg = postData;
UTF8Encoding encoding = new UTF8Encoding();
byte[] byte1 = encoding.GetBytes(postData);
string dataToSign = "(request-target): post " + gatewayurl + signUrl + "\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" +
postData;
string hmac = generateAuthHeader(dataToSign, apisecret);
string authorisation = "Signature keyId=\"" + apikey + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date content-type content-length\",signature=\"" + hmac + "\"";
resolveResponse responseValue = new resolveResponse();
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", authorisation);
client.DefaultRequestHeaders.Add("Cache-Control", "no-cache");
ByteArrayContent content = new ByteArrayContent(byte1);
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestendpoint);
request.Headers.Add("Date", dateValue.ToString("r"));
request.Content = content;
HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
}
Postman
Can you please help me find a solution?