雅虎api用于幻想体育。无法想象如何使用访问令牌

时间:2017-09-12 04:35:43

标签: c# yql

我有访问令牌。如何在c#中使用令牌发出请求? 以下是我尝试失败的结果error 400 Bad Request

注意:该网址是从YQL控制台复制的

public static void Request(string token)
        {
            var request =
                WebRequest.Create(
                    @"https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20fantasysports.leagues%20where%20league_key%3D'371.l.4019'&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys");

            request.Headers["Authorization"] = $"Bearer {token}";
            request.Method = "GET";
            request.ContentType = "application/xml;charset=UTF-8";
            using (var response = request.GetResponse())
            {
                using (var stream = response.GetResponseStream())
                {
                    if (stream == null) return;
                    var reader = new StreamReader(stream, Encoding.UTF8);
                    var responseString = reader.ReadToEnd();
                }
            }
        }

0 个答案:

没有答案