Hello, I want to update the title and the game in C#, but I get the error forbidden.
Here’s my C# httpClient code:
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("PUT"), "https://api.twitch.tv/kraken/channels/" + Settings.Default.ChannelID))
{
request.Headers.TryAddWithoutValidation("Accept", "application/vnd.twitchtv.v5+json");
request.Headers.TryAddWithoutValidation("Authorization", "OAuth " + Settings.Default.ChannelToken);
request.Headers.TryAddWithoutValidation("Client-ID", Settings.Default.ClientID);
request.Content = new StringContent("{\"channel\": {\"status\": \"Test\", \"game\": \"Overwatch\", \"channel_feed_enabled\": true}}", Encoding.UTF8, "application/json");
var response = await httpClient.SendAsync(request);
Console.WriteLine(response.StatusCode);
}
}
The channelID, OAuth token and client id is saved in the application settings, and it shouldn’t be a problem, because the TwitchLib library works perfectly fine.
I printed out the variables in the console and none of the variables is empty.
I’m fairly new to C# so… can you explain how I do that?
I tried it using this command:
var body = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(body);
Oh yes sorry, I forgot to tell about that. I already visited that link (actually I’m using the public documentation all the time) and I also saw I need that scope.
That’s my request url:
Get GZIP compression enabled for your call (to update the channel) and you’ll be able to read the error body response.
You can also totally remove channel_feed_enabled from your JSON as the feed is dead/removed feature, it’s just in the docs for completeness
If you call channel_feed_enabled you need channel_editor from the channel you are trying to update.
Otherwise
You need a key with channel_editor on for YOU and YOU are also an editor on the target channel.
-OR-
You need a key with channel_editor on for the channel you wish to update.
Unless you are trying to update your own personal channel, I anticipate you have the wrong owner of the key
Ok well… looks like that was the problem…
I removed the channel_feed_enabled from the json and it looks like it’s working now. Thank you very much! I spent my last view hours with that problem
You saved me! Thank you