Content Delivery API properties missing with expand
c
I am new to umbraco and trying to build a site as a learning project. I am trying to use
?expand=all
on the content api but properties of some nested content is empty. is about 4 levels deep in response object
what is confusing is i have other objects in same content reponse that actually go slightly deeper
t
Umbraco has ControllerBase and SufaceController u can try
c
does this allow me to modify default content delivery api response?
i saw soemthing about value converter but not sure
t
Yes, u can modified response
from my project, im use converter class for this one
p
@Conner Did you get any further with this using the 'expand' query? I'm currently attempting to bring back a Multi Node Tree Picker item properties that is within a Block Grid item. I'm pretty certain it's possible based on the documentation: https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/property-expansion-and-limiting#block-grid It's just getting the correct query that I'm finding tricky/fiddly.
c
i didn't, reading docs i dont know if it is possible to expose.
u xcan onyl populate 1 level deep on picker, so my understanding:
Copy code
node_picker_1 (level 1, blogs)
  properties {object has values}
  
  node-picker_2 (level 2, tags)
    properties {object empty}
so on blog articles list page for instance, I have node picker to select blogs and inside blog document type, there is also tag picker.
my 2 options were: 1) create custom route to delivery list of blogs and fetch on frontend (so i would have 2 fetch in frontend, blog page content + blog articles list) or the solution I went with 2) tag properties is empty, but culture name is not - so I wrote some c# and hooked into
contentsavingnotification
then set culture name = field name so with option 2, the API response from node_picker_2 gives me only tag culture name, so i use this value
it is not ideal, but for my problem it worked great
Copy code
node_picker_1 (level 1, blogs)
  properties {
     ..list of blogs
     [{
         node-picker_2 (level 2, tags)
         properties {object empty}
     }]
  }
looks more like this sorry.
where picker_2 is tags and is a property of picker_1
p
Makes sense. At least you found a work around. Maybe I have a different challenge.
Copy code
"componentGrid": {
    "gridColumns": 12,
    "items": [
        {
            "rowSpan": 1,
            "columnSpan": 12,
            "areaGridColumns": 12,
            "areas": [],
            "content": {
                "contentType": "exampleComponent",
                "id": "454ced18-fdc5-490a-8edc-1bec1eb49230",
                "properties": {
                    "title": "Title",
                    "text": "Lorem Ipsum Sherpa",
                    "pickedItem": [
                        {
                            "contentType": "examplePickedItem",
                            "name": "Primary",
                            "createDate": "2024-01-25T10:36:57.9685796",
                            "updateDate": "2024-01-25T10:36:57.9685796",
                            "route": {
                                "path": "/items/example/",
                                "startItem": {
                                    "id": "193e6f34-249b-45e8-8088-053bd2048b83",
                                    "path": "settings"
                                }
                            },
                            "id": "0128a332-ae44-4fdb-a99d-4c09ea643aac",
                            "properties": {
                                // These are the properties I'm trying to expand
                            }
                        }
                    ]
                }
            },
            "settings": null
        }
    ]
}
At the moment, this is my query: expand= properties[componentGrid[properties[pickedItem[properties[$all]]]]]
c
i just pass
?expand=all
pls try passing that to end of url only
it may open up for you, not 100%
p
Nice. That has done it. I had passed expand=$all (I'm sure i've seen $all in the docs before - but could just be me) Ideally I'd also like to only expand what I need, but this will get me going for testing. If anyone else has any pointers on limiting the expantion based on the above, please let me know 🙂
Thanks @Conner
c
yeah sadly i couldn't figure out how to
expand=all was a ugly workaround
hopefully someone more experienced in Umbraco can chime in soon
p
That really should be me 😅 This is great for where I'm at now. Juggling the closing ']]]]]]]' within postman was slowly driving me mad 😂
c
yup exactly why i avoided that lol
esepcially as every fetch from frontend has to be tailored with [][][][][]
whereas 1 simple expand=all
u can set a max-depth, so if ur data will exceed it, error is thrown
p
Nice, I'll try that too. Thank you! In my case, I'm using it to power a static site, so it's not a massive issue if I return everything. Still, would be great to understand how.
333 Views