c# - Yahoo api for fantasy sports. Cannot figure how to use access token -
i have access token. how can make request using token in c#? here have tried unsuccessfully resulting in error 400 bad request
.
note: url copied yql console
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(); } } }
Comments
Post a Comment