Hi,
for the past week we able to run our code without any issues.
but i came to notice that recently the BST time zone has changed.so when i run this code inorder to retrieve the case template or even for a top level groups i was shockingly stucked by the error 401 unauthorised.
below i am proving my code foe getting the toplevel groups.can you kindly help me ASAP.since we are running in prod.
for getting toplevelgrups i have used the following
DateTime dateValue = DateTime.UtcNow; // get the datetime NOW GMT
string dataToSign = "(request-target): get " + GlobalProperties.GateWayUrl + "groups\n" + "host: " + GlobalProperties.GatewayHost + "\n" + "date: " + dateValue.ToString("R");
DateTime dateValue = DateTime.UtcNow; // get the datetime NOW GMT DateTime localDateTime = DateTime.Now; DateTime utcDateTime = localDateTime.ToUniversalTime(); string nzTimeZoneKey = "GMT Standard Time"; TimeZoneInfo nzTimeZone = TimeZoneInfo.FindSystemTimeZoneById(nzTimeZoneKey); DateTime nzDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcDateTime, nzTimeZone); string authorisation = ""; string hmac = generateAuthHeader(datatoSign, GlobalProperties.APISecret); HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(reqEndPoint); WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials; //using (WebReq as IDisposable) //{ WebReq.Method = methodType; WebReq.Headers.Add("Cache-Control", "no-cache"); WebReq.Date = nzDateTime;
if (methodType == "GET")
{
authorisation = "Signature keyId=\"" + ConfigurationManager.AppSettings["apikey"] + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"" + hmac + "\""; //authorisation = "Signature keyId=\"" + ConfigurationManager.AppSettings["apikey"] + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"" + hmac + "\""; WebReq.Headers.Add("Authorization", authorisation); }
try { using (HttpWebResponse response = (HttpWebResponse)WebReq.GetResponse()) { using (Stream answer = response.GetResponseStream()) { StreamReader _Answer = new StreamReader(answer); dynamic responseData = Newtonsoft.Json.JsonConvert.DeserializeObject(_Answer.ReadToEnd()); answer.Dispose(); answer.Close(); response.Dispose(); response.Close(); return responseData; } } } catch (WebException e) { }
@Irfan.Khan,i have also added the GMT timezone to request header but seems to b not working
Many thanks in advance.