My problem, as you can see in the title, is I get an exception when adding the header. What I'm trying to do is send an authorization request to the public TwitchAPI. Here's the request that I'm trying to translate:
curl -H 'Accept: application/vnd.twitchtv.v3+json'
-H 'Authorization: OAuth <access_token>' \
-X GET https://api.twitch.tv/kraken/channel
It's when I add the Accept header where this exception pops up in my face (title). I'm not sure if I've translated this correctly but this is the code I have right now:
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)
where oauth_token is my access token, anyone who could solve this for me? Really worked my ass off trying to figure out such a simple thing, thanks!
The HttpWebRequest
class has a specific Accept
property for setting the 'Accept' header
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With