I messed up somewhere and I am having some trouble with getting the JsonConvert to convert a response to my model. I am trying to call the twitch endpoint here: https://tmi.twitch.tv/group/user/CHANNEL/chatters and get the list of viewers.
Here is my code:
{
using var client = new HttpClient();
var res = await client.GetAsync("https://tmi.twitch.tv/group/user/" + streamer + "/chatters").ConfigureAwait(false);
if (res.IsSuccessStatusCode)
{
var str = await res.Content.ReadAsStringAsync();
var response = JsonConvert.DeserializeObject<response>(str);
return response;
}
return null;
}```
and finally here is my model:
public class Response
{
[JsonProperty("chatter_count")]
public long ChatterCount { get; set; }
[JsonProperty("broadcaster")]
public string[] Broadcaster { get; set; }
[JsonProperty("vips")]
public string[] Vips { get; set; }
[JsonProperty("moderators")]
public string[] Moderators { get; set; }
[JsonProperty("staff")]
public object[] Staff { get; set; }
[JsonProperty("admins")]
public object[] Admins { get; set; }
[JsonProperty("global_mods")]
public object[] GlobalMods { get; set; }
[JsonProperty("viewers")]
public string[] Viewers { get; set; }
}
}```
Whenever I try to call my method to get the viewers I am getting App.Response with everything in the model being null even though whenever I use the same URL to in Postman or browser I get valid data back. and the
var str = ""{\n "_links": {},\n "chatter_count": 2,\n "chatters": {\n "broadcaster": [],\n "vips": [],\n
"moderators": [\n "nightbot"\n ],\n "staff": [],\n
"admins": [],\n "global_mods": [],\n "viewers": [\n
"heirmanttinan"\n ]\n }\n}\n""