Hi. I'm trying to run a profile check on the World-Check One API in C# but I can't get the following code to work. Any help would be appreciated:
DateTime dateValue = DateTime.UtcNow; string apikey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; string apisecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string gatewayurl = "/v1/"; string gatewayhost = "rms-world-check-one-api-pilot.thomsonreuters.com"; string requestendpoint = "https://rms-world-check-one-api-pilot.thomsonreuters.com/v1/reference/profile/e_tr_wci_2221"; string date = dateValue.ToString("R"); string dataToSign = "(request-target): get " + gatewayurl + "reference/profile/" + HttpUtility.UrlEncode("e_tr_wci_2221") + "\n" + "host: " + gatewayhost + "\n" + // no https only the host name "date: " + date + "\n"; // GMT date as a string string hmac = generateAuthHeader(dataToSign, apisecret); string authorisation = "Signature keyId=\"" + apikey + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"" + hmac + "\""; HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(requestendpoint); WebReq.Method = "GET"; WebReq.Headers.Add("Authorization", authorisation); WebReq.Headers.Add("Date", date); //WebReq.Headers.Add("Cache-Control", "no-cache"); WebReq.Date = dateValue; // use datetime value GMT time HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();//code execution fails here Stream Answer = WebResp.GetResponseStream(); StreamReader reader = new StreamReader(Answer); string html = reader.ReadToEnd();
Thanks.