C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
7,604 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I am trying to use Sentry.ip API but I am not getting any result and no error.
Here is my code:
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "xxxxxxxxxxxxx");
httpClient.BaseAddress = new Uri("https://sentry.io/api/0/projects/");
var response = await httpClient.GetAsync("https://sentry.io/api/0/projects/");
var result = await response.Content.ReadAsStringAsync();
ProjectsData.Root data = JsonSerializer.Deserialize<ProjectsData.Root>(result);
ListViewHomePage.ItemsSource = data;
and this is my class:
using System;
namespace Sentry
{
class ProjectsData
{
// Root myDeserializedClass = JsonConvert.DeserializeObject<List<Root>>(myJsonResponse);
public class Avatar
{
public string avatarType { get; set; }
public object avatarUuid { get; set; }
}
public class Links
{
public string organizationUrl { get; set; }
public string regionUrl { get; set; }
}
public class Organization
{
public string id { get; set; }
public string slug { get; set; }
public Status status { get; set; }
public string name { get; set; }
public DateTime dateCreated { get; set; }
public bool isEarlyAdopter { get; set; }
public bool require2FA { get; set; }
public bool requireEmailVerification { get; set; }
public Avatar avatar { get; set; }
public List<string> features { get; set; }
public Links links { get; set; }
}
public class Root
{
public string id { get; set; }
public string slug { get; set; }
public string name { get; set; }
public bool isPublic { get; set; }
public bool isBookmarked { get; set; }
public string color { get; set; }
public DateTime dateCreated { get; set; }
public DateTime? firstEvent { get; set; }
public bool firstTransactionEvent { get; set; }
public bool hasSessions { get; set; }
public bool hasProfiles { get; set; }
public List<string> features { get; set; }
public string status { get; set; }
public string platform { get; set; }
public bool isInternal { get; set; }
public bool isMember { get; set; }
public bool hasAccess { get; set; }
public Avatar avatar { get; set; }
public Organization organization { get; set; }
}
public class Status
{
public string id { get; set; }
public string name { get; set; }
}
}
}
Kindly help..
Thanks,
Jassim
If the result string contains the expected JSON data, then maybe your classes are not good. Did you check the result variable during debugging?