c# - Vuforia bad request 400


Keywords:c# 


Question: 

I'm trying to GET all my markets from Vuforia API, but when i send my request according from this url Authorization: VWS {provision_access_key}:{Signature} the response is: BAD Request 400. Could be the problem in the "header", because the signature it is ok.

This is part of my code;

var webRequest = System.Net.HttpWebRequest.Create(WEBSERVICE_URL);
            HttpWebRequest httpWReq = (HttpWebRequest)HttpWebRequest.Create(WEBSERVICE_URL);
            MethodInfo priMethod = httpWReq.Headers.GetType().GetMethod("AddWithoutValidate", BindingFlags.Instance | BindingFlags.NonPublic);
            priMethod.Invoke(webRequest.Headers, new[] { "Date", strDate });

            if (webRequest != null)
            {
                webRequest.Method = "GET";
                webRequest.Timeout = 12000;
                //webRequest.ContentType = "application/json";

                string strSign = CrearStringToSign(webRequest);
                string sendWsVuforia = "AWS " + Configuracion.accessKey + ":" + strSign;
                string strHeadType = "application/json";
                string strHeadDate = strDate;

                priMethod.Invoke(webRequest.Headers, new[] { "Authorization", sendWsVuforia });
                priMethod.Invoke(webRequest.Headers, new[] { "Content-Type", "" });


                using (System.IO.Stream s = webRequest.GetResponse().GetResponseStream())
                {
                    using (System.IO.StreamReader sr = new System.IO.StreamReader(s))
                    {
                        var jsonResponse = sr.ReadToEnd();
                        Console.WriteLine(String.Format("Response: {0}", jsonResponse));
                    }
                }

1 Answer: 

You're using AWS instead of VWS in your authorization header.

string sendWsVuforia = "AWS " + Configuracion.accessKey + ":" + strSign;

should be

string sendWsVuforia = "VWS " + Configuracion.accessKey + ":" + strSign;