I am using .aspnetcore 6 and the response object is not correctly searialized.
public class AvailableColumns
{
public List<Column> Columns { get; } = new List<Column>();
}
public class Column
{
public string Name { get; set; }
public List<Value> Values { get; set; } = new List<Value>();
}
public class Value
{
public string InternalValue { get; set; }
public string DisplayName { get; set; }
}
That way the code is read:
// Before this line there are 20 columns in the object T.
response.Data = await response.Content.ReadFromJsonAsync<T>();
// After response.Data has 0 columns
How to fix it?
CodePudding user response:
Not sure how is your api like, be sure your api actually returns AvailableColumns model with data.
Be sure add the
set
accessor for theColumns
property.public class AvailableColumns { public List<Column> Columns { get; set; } = new List<Column>(); //add set accessor here }