Hello,
In our model, we have an Article with an array field of reference for Category.
Unfortunately, when I pull entries with the delivery SDK the first item in the array is always null.
I did run a migration to copy from another field into a new categories field… i’m wondering if it created it differently…
i’m a little lost so any help is appreciated!
Digging into the Contentful Client, I see it has both when it deserializes but it always fails to resolve the first one:
Query:
var query = QueryBuilder<ContentfulArticleModel>.New
.ContentTypeIs(contentType.Key.ToString().ToCamelCase())
.FieldIncludes("fields.slug", ids)
.Include(ContentfulConstants.Config.DefaultLevel);
var result = await _cmsClient.GetEntries(query, token);
return result;
ContentfulArticleModel:
internal class ContentfulArticleModel
{
public SystemProperties Sys { get; set; }
public string Title { get; set; }
public string Excerpt { get; set; }
public string[] Tags { get; set; }
public string Slug { get; set; }
public ContentfulCategoryModel[] Categories { get; set; }
public Asset SmallThumbnail { get; set; }
public AlgoliaArticleModel Convert()
{
return new AlgoliaArticleModel
{
ObjectId = Sys.Id,
Title = Title,
Content = Excerpt ?? Title,
Tags = Tags != null && Tags.Any() ? string.Join(",", Tags) : string.Empty
};
}
}
and finally ContentfulCategoryModel
internal class ContentfulCategoryModel
{
public string Title { get; set; }
}