When trying to post a case using my own API key and secret I'm receiving error code 401 everytime. I'm using the sample code provided in the C# example for the generateAuthHeader function, and have been able to call GET requests without issue.
The string I'm using for my content is:
{\"secondaryFields\":[],\"entityType\":\"INDIVIDUAL\",\"customFields\":[],\"groupId\":\"" + GroupId + "\",\"providerTypes\":[\"WATCHLIST\"],\"name\":\"乔治布什\"} with GroupId being replaced with ''.
My Data To Sign is formatted as follows:
(request-target): post /v1/cases
host: rms-world-check-one-api-pilot.thomsonreuters.com
date: Tue, 03 Jul 2018 12:59:32 GMT
content-type: application/json
content-length: 167
{"secondaryFields":[],"entityType":"INDIVIDUAL","customFields":[],"groupId":"0a3687cf-63f9-125f-9904-7a1500000298","providerTypes":["WATCHLIST"],"name":"乔治布什"}
Is there something I'm missing?
For reference, below is the .Net code that I'm using to generate the hmac:
public static string generateAuthHeader(string dataToSign, string apisecret)
{
byte[] secretKey = Encoding.UTF8.GetBytes(apisecret);
HMACSHA256 hmac = new HMACSHA256(secretKey);
hmac.Initialize();
byte[] bytes = Encoding.UTF8.GetBytes(dataToSign);
byte[] rawHmac = hmac.ComputeHash(bytes);
Console.WriteLine("---rawHmac---");
string hex = BitConverter.ToString(rawHmac).Replace("-", "");
Console.WriteLine(hex);
return (Convert.ToBase64String(rawHmac));
}