Vuforia不好请求400

时间:2018-02-08 22:46:39

标签: c# augmented-reality vuforia

我正在尝试从Vuforia API获取我的所有市场,但是当我根据此网址Authorization: VWS {provision_access_key}:{Signature}发送我的请求时  响应是:BAD请求400.可能是“标题”中的问题,因为签名没问题。

这是我的代码的一部分;

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 个答案:

答案 0 :(得分:0)

您在授权标题中使用AWS而不是VWS

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

应该是

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