正如您在标题中所看到的,我的问题是在添加标题时我得到了一个异常。我要做的是向公共TwitchAPI发送授权请求。以下是我试图翻译的请求:
curl -H 'Accept: application/vnd.twitchtv.v3+json'
-H 'Authorization: OAuth <access_token>' \
-X GET https://api.twitch.tv/kraken/channel当我添加Accept时,这个异常会出现在我的脸上(标题)。我不确定我是否正确地翻译了这段代码,但这是我现在拥有的代码:
Dim wr = CType(WebRequest.Create("https://api.twitch.tv/kraken/channel"), HttpWebRequest)
wr.Method = "GET"
wr.Headers.Add("Authorization: OAuth <oauth_token>")
wr.Headers.Add("Accept: application/vnd.twitchtv.v3+json")
Return CType(wr.GetResponse(), HttpWebResponse)oauth_token在哪里是我的访问令牌,谁能帮我解决这个问题?我真的很努力想弄明白这么简单的事情,谢谢!
发布于 2015-04-08 17:30:38
HttpWebRequest类具有一个特定的Accept属性,用于设置“接受”标头
Dim wr = CType(WebRequest.Create("https://api.twitch.tv/kraken/channel"), HttpWebRequest)
wr.Method = "GET"
wr.Headers.Add("Authorization: OAuth <oauth_token>")
wr.Accept = "application/vnd.twitchtv.v3+json"
Return CType(wr.GetResponse(), HttpWebResponse)https://stackoverflow.com/questions/29514443
复制相似问题