Delivery API CollectionView not expanded (returned...
# help-with-umbraco
x
I have a structure as shown in the image. Blogs, blogs have categories and categories have articles. but with this query (expand all, properties all, path: blogs)
Copy code
ps
curl -X 'GET' \
  'https://localhost:5151/umbraco/delivery/api/v2/content/item/blogs?expand=properties%5B%24all%5D&fields=properties%5B%24all%5D' \
  -H 'accept: application/json'
i get this result
Copy code
json
{
  "contentType": "blogs",
  "name": "Blogs",
  "createDate": "2024-07-19T15:21:02.723Z",
  "updateDate": "2024-07-19T15:37:37.753Z",
  "route": {
    "path": "/cz/blogs/",
    "startItem": {
      "id": "cb4a02ea-0f37-4aaf-9ccc-0f7386d67e79",
      "path": "blogs"
    }
  },
  "id": "cb4a02ea-0f37-4aaf-9ccc-0f7386d67e79",
  "properties": {
    "blogCategories": null
  },
  "cultures": {
    "en-US": {
      "path": "/en/blogs/",
      "startItem": {
        "id": "cb4a02ea-0f37-4aaf-9ccc-0f7386d67e79",
        "path": "blogs"
      }
    },
    "cs-CZ": {
      "path": "/cz/blogs/",
      "startItem": {
        "id": "cb4a02ea-0f37-4aaf-9ccc-0f7386d67e79",
        "path": "blogs"
      }
    }
  }
}
blogCategories property is null. How can i get the content such that i can access the blogCategories? https://cdn.discordapp.com/attachments/1263856590285443103/1263856590835023945/image.png?ex=669bc1ac&is=669a702c&hm=9615281025172f53b19a7e42cdc8d87ab122abd78ba618c38e454e844f980c67&
My solution for now is to go with this mess, which makes the delivery api useless, but it is what it is...
Copy code
cs
        var categories = blogs!.Children
            .Select(c => new BlogCategoryResponse(
                c.GetProperty("title")!.GetValue()!.ToString()!,
                c.Children.Select(a => new BlogArticleResponse(
                    a.GetProperty("title")!.GetValue()!.ToString()!,
                    a.GetProperty("body")!.GetValue()!.ToString()!
                ))
                    .ToArray()
            ))
            .ToArray();
4 Views