Hello, I have a problem when it comes to consuming data from an api rest. I have the following class:
public partial class Assignee
{
[JsonProperty("self")]
public Uri Self { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("key")]
public string Key { get; set; }
[JsonProperty("accountId")]
public string AccountId { get; set; }
[JsonProperty("emailAddress")]
public string EmailAddress { get; set; }
[JsonProperty("avatarUrls")]
public Urls AvatarUrls { get; set; }
[JsonProperty("displayName")]
public string DisplayName { get; set; }
[JsonProperty("active")]
public bool Active { get; set; }
[JsonProperty("timeZone")]
public TimeZone TimeZone { get; set; }
}
And as soon as I start, I want you to return the email, for example, and I try like this:
private const string Url = "https://xxx.xxx/res/apixxx.json";
protected override void OnAppearing()
{
var client = new RestClient(Url);
var request = new RestRequest(Method.GET);
request.AddHeader("Postman-Token", "683c-b7567-42c-8dea-f90f567");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Authorization", "Basic Yyryrty56456JG");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
IRestResponse response = client.Execute(request);
var content = JsonConvert.DeserializeObject<Assignee>(response.Content);
LblText.Text = content.EmailAddress;
}
I think I'm not very clear on the issue of Deserializar un json, Visual Studio does not return any error, but it does not show me anything on the screen, does anyone know what I'm failing? Thanks.