Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ras 61 posts 324 karma points
    Dec 21, 2023 @ 15:04
    Ras
    0

    Content delivery API - how to filter on nested properties?

    Hi, I'm using the latest Umbraco v13.0.2 and starting to try out the Content delivery api. Can do simple filtering like:

    /umbraco/delivery/api/v1/content?filter=contentType:event&filter=startDate>:2023-01-01
    

    But how about if I want to access something deeper in the content? say my event doctype returns this structure:

    "contentType": "event",
        "properties": {
            "someProperty": 123,
            "anotherProperty: {
                    "id": 456
                }
        }
    

    How would I make a filtering query to filter on the someProperty, or the id in anotherProperty? Does this require extending the api?

  • pbl_dk 150 posts 551 karma points
    Jan 07, 2024 @ 17:32
    pbl_dk
    0

    I have tried 10 different queries like:

     filter=property[postalCode]:8000
     filter=property.postalCode:8000
     filter=postalCode:8000
     filter=properties[postalCode]:8000
    

    nothing works, seems its not implemented, can't find anything about it in docs either.

    I am going to try to make my own filter method as docs says here: https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/extension-api-for-querying#custom-filter

  • Bjarne Fyrstenborg 1280 posts 3990 karma points MVP 7x c-trib
    Jan 08, 2024 @ 07:54
    Bjarne Fyrstenborg
    0

    Did you try v2 of delivery API as the documentation mention? I am not sure it was available in v1?

    I haven't tested it myself though.

  • Ras 61 posts 324 karma points
    Jan 08, 2024 @ 14:23
    Ras
    0

    Yes, it doesn't work unfortunately. As the indexer indexes based on the guid in the content picker, but the multinode picker returns a comma separated string with all the guids based on the nodes picked, I had to create a method that extracts each guid into its own object and indexes them each by themselves.

  • pbl_dk 150 posts 551 karma points
    Jan 08, 2024 @ 14:07
    pbl_dk
    0

    Hi Bjarne

    I am not sure I am doing it right, but all of these returns an error:

    &filter=properties[klubID]:K88000
    &filter=klubID:K88000
    &filter=klubID
    &filter=properties.klubID:K8800
    &filter=properties[klubID]:K8800
    

    /api/v2/content?fetch=children:e5502e78-4b12-42d7-b58f-5220c91027b8&filter=properties[klubID]:K8800

    {"type":"Error","title":"Filter option not found","status":400,"detail":"One of the attempted \u0027filter\u0027 options does not exist"}

  • Busra Sengul 9 posts 112 karma points MVP 3x c-trib
    Jan 26, 2024 @ 14:24
    Busra Sengul
    0

    You need to add a custom filter for your property.

    https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/extension-api-for-querying#custom-filter

    In terms of getting the pickers' information, I recently did this, and injected IContentService to get the content itself and used the properties to add to the index. then you can retrieve it by

    umbraco/delivery/api/v1/content?filter=customFilter:something

    Hope this make sense :)

Please Sign in or register to post replies

Write your reply to:

Draft