string imgurID = "";
string html = string.Empty;
string url = @"https://api.imgur.com/3/gallery/r/nsfw/top/";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Headers["Authorization"] = $"Client-ID {imgurID}";
request.AutomaticDecompression = DecompressionMethods.GZip;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
html = reader.ReadToEnd();
}
try
{
ImgurRoot root;
var json = JsonConvert.DeserializeObject(html);
root = JsonConvert.DeserializeObject<ImgurRoot>(html);
ADebug.LogDebug(root.link); //This is Empty
var index = new Random().Next(0, 100);
ADebug.LogDebug(json);
}
catch(Exception e)
{
ADebug.LogCriticalError(e);
}
In this code i need to get the link from a post from imgur, and those posts are sorted by an index called "data" and i need to get the link for that post, but i don't know how to get just the link for one post and when i tried to get the link for all posts, the link is empty
ImgurRoot:
public class ImgurRoot
{
public string id { get; set; }
public string title { get; set; }
public string description { get; set; }
public string datetime { get; set; }
public string type { get; set; }
public string animated { get; set; }
public string width { get; set; }
public string height { get; set; }
public string size { get; set; }
public string views { get; set; }
public string bandwidth { get; set; }
public string vote { get; set; }
public string favorite { get; set; }
public string nsfw { get; set; }
public string section { get; set; }
public string account_url { get; set; }
public string account_id { get; set; }
public string is_ad { get; set; }
public string is_most_viral { get; set; }
public string has_sound { get; set; }
public string tags { get; set; }
public string ad_type { get; set; }
public string ad_url { get; set; }
public string in_gallery { get; set; }
public string link { get; set; }
public string comment_count { get; set; }
public string ups { get; set; }
public string downs { get; set; }
public string points { get; set; }
public string score { get; set; }
public string is_album { get; set; }
}
How i can fix this?

HttpWebResponseis? That usually provides some information on why you're not getting what you think you should.