I am trying to implement vuforia api in c # code.
I get an error message from the server.
C # code:
ASCIIEncoding Encoding = new ASCIIEncoding(); MD5 md5 = MD5.Create(); string requestPath = "/targets"; string serviceURI = "https://vws.vuforia.com"+ requestPath; string httpVerb = "GET"; var contentMD5bytes = md5.ComputeHash(Encoding.GetBytes("")); string contentMD5 = BitConverter.ToString(contentMD5bytes).Replace("-", ""); string contentType = ""; System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); string date = string.Format("{0:r}", DateTime.Now.ToUniversalTime()); string StringToSign = String.Format("{0}\n{1}\n{2}\n{3}\n{4}", httpVerb, contentMD5, contentType, date, requestPath); // HTTP-Verb, Content-MD5, Content-Type, Date, Request-Path; HMACSHA1 sha1 = new HMACSHA1(System.Text.Encoding.ASCII.GetBytes(secretKey)); byte[] sha1Bytes = Encoding.GetBytes(StringToSign); MemoryStream stream = new MemoryStream(sha1Bytes); byte[] sha1Hash = sha1.ComputeHash(stream); string signature = System.Convert.ToBase64String(sha1Hash); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(serviceURI); request.Headers.Add("Authorization", string.Format("VWS {0}:{1}", accessKey, signature)); request.Date = DateTime.Now.ToUniversalTime(); try { using (HttpWebResponse responses = request.GetResponse() as HttpWebResponse) { if (responses.StatusCode == HttpStatusCode.OK) { // Do stuff with response.GetResponseStream(); } } } catch (WebException ex) { }
Upon reaching
The following error appears:
WebResponse tResponse = tRequest.GetResponse();
Error: {"The remote server returned an error: (401)" Unauthorized ".}
I named the following URLs
https://developer.vuforia.com/forum/qcar-api/vms-api-using-c
Can anyone provide a solution for this.
c # api vuforia
chozha rajan
source share