Help with OData $search or $filter

Hi there,

I am trying to get a single item from a collection if items.
The collection contains the following from this get url: https://cloud.squidex.io/api/content/app-name/items (url been modified to hide app and endpoint)

{
"total": 3,
"items": [
    {
        "id": "f76f0d6c-a227-4fb5-a0d6-33d8c0abcbd0",
        "createdBy": "subject:58fe32caf3ca3d0001ef41c8",
        "lastModifiedBy": "subject:58fe32caf3ca3d0001ef41c8",
        "data": {
            "articleTitle": {
                "iv": "artikel 1 lorem ipsum dolor sit amet consectuer"
            },
            "articleImage": {
                "iv": [
                    "a7187ba8-ae14-43b5-baf0-873f8399203c"
                ]
            },
            "articleContent": {
                "iv": "<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Id illum reprehenderit cumque placeat magni animi provident est sapiente accusamus iure deserunt, exercitationem amet officia ducimus quam perspiciatis quos aliquam libero.</p>\n<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Id illum reprehenderit cumque placeat magni animi provident est sapiente accusamus iure deserunt, exercitationem amet officia ducimus quam perspiciatis quos aliquam libero.</p>\n<ul>\n<li>Limburg heeft vier&nbsp;<a title=\"brightlands\" href=\"https://www.brightlands.com/\" target=\"_blank\" rel=\"noopener\">Brightlands campussen</a>&nbsp;waar gewerkt wordt aan de nieuwste innovaties op het gebied van materialen, gezondheid, slimme digitale diensten en voeding</li>\n<li>Limburg is van oudsher een grote speler in de industrie.</li>\n<li>Limburg is koploper wat betreft internationaal samenwerken: Duitsland en Belgi&euml; zijn vaste partners van de meeste Limburgse bedrijven.</li>\n</ul>\n<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Id illum reprehenderit cumque placeat magni animi provident est sapiente accusamus iure deserunt, exercitationem amet officia ducimus quam perspiciatis quos aliquam libero.</p>\n<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Id illum reprehenderit cumque placeat magni animi provident est sapiente accusamus iure deserunt, exercitationem amet officia ducimus quam perspiciatis quos aliquam libero.</p>"
            },
            "articleCategory": {
                "iv": [
                    "Blog"
                ]
            }
        },
        "created": "2020-03-30T08:52:05Z",
        "lastModified": "2020-03-31T12:13:31Z",
        "status": "Published",
        "statusColor": "#4bb958",
        "schemaName": "items",
        "schemaDisplayName": "items",
        "version": 5,
        "_links": {
            "self": {
                "href": "/api/content/app-name/items/f76f0d6c-a227-4fb5-a0d6-33d8c0abcbd0",
                "method": "GET"
            },
            "previous": {
                "href": "/api/content/app-name/items/f76f0d6c-a227-4fb5-a0d6-33d8c0abcbd0/4",
                "method": "GET"
            }
        }
    },
    {
        "id": "852bec4f-b276-40dc-8cef-dffc2b7c8068",
        "createdBy": "subject:58fe32caf3ca3d0001ef41c8",
        "lastModifiedBy": "subject:58fe32caf3ca3d0001ef41c8",
        "data": {
            "articleTitle": {
                "iv": "artikel 2 lorem ipsum dolor sit amet consectuer"
            },
            "articleImage": {
                "iv": [
                    "b3ae84ba-22fd-46a4-bbcd-5e15128d1004"
                ]
            },
            "articleContent": {
                "iv": "<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Id illum reprehenderit cumque placeat magni animi provident est sapiente accusamus iure deserunt, exercitationem amet officia ducimus quam perspiciatis quos aliquam libero.</p>\n<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Id illum reprehenderit cumque placeat magni animi provident est sapiente accusamus iure deserunt, exercitationem amet officia ducimus quam perspiciatis quos aliquam libero.</p>\n<ul>\n<li>Limburg heeft vier&nbsp;<a title=\"brightlands\" href=\"https://www.brightlands.com/\" target=\"_blank\" rel=\"noopener\">Brightlands campussen</a>&nbsp;waar gewerkt wordt aan de nieuwste innovaties op het gebied van materialen, gezondheid, slimme digitale diensten en voeding</li>\n<li>Limburg is van oudsher een grote speler in de industrie.</li>\n<li>Limburg is koploper wat betreft internationaal samenwerken: Duitsland en Belgi&euml; zijn vaste partners van de meeste Limburgse bedrijven.</li>\n</ul>\n<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Id illum reprehenderit cumque placeat magni animi provident est sapiente accusamus iure deserunt, exercitationem amet officia ducimus quam perspiciatis quos aliquam libero.</p>"
            },
            "articleCategory": {
                "iv": [
                    "Blog"
                ]
            }
        },
        "created": "2020-03-30T09:02:47Z",
        "lastModified": "2020-03-31T12:13:26Z",
        "status": "Published",
        "statusColor": "#4bb958",
        "schemaName": "items",
        "schemaDisplayName": "items",
        "version": 4,
        "_links": {
            "self": {
                "href": "/api/content/app-name/items/852bec4f-b276-40dc-8cef-dffc2b7c8068",
                "method": "GET"
            },
            "previous": {
                "href": "/api/content/app-name/items/852bec4f-b276-40dc-8cef-dffc2b7c8068/3",
                "method": "GET"
            }
        }
    },
    {
        "id": "718cfeca-789d-4843-95f8-45e513bbcac5",
        "createdBy": "subject:58fe32caf3ca3d0001ef41c8",
        "lastModifiedBy": "subject:58fe32caf3ca3d0001ef41c8",
        "data": {
            "articleTitle": {
                "iv": "artikel 3 lorem ipsum dolor sit amet consectuer"
            },
            "articleImage": {
                "iv": [
                    "1d364bca-d587-483f-8f13-3fc5a68f898e"
                ]
            },
            "articleContent": {
                "iv": "<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Id illum reprehenderit cumque placeat magni animi provident est sapiente accusamus iure deserunt, exercitationem amet officia ducimus quam perspiciatis quos aliquam libero.</p>\n<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Id illum reprehenderit cumque placeat magni animi provident est sapiente accusamus iure deserunt, exercitationem amet officia ducimus quam perspiciatis quos aliquam libero.</p>\n<ul>\n<li>Limburg heeft vier&nbsp;<a title=\"brightlands\" href=\"https://www.brightlands.com/\" target=\"_blank\" rel=\"noopener\">Brightlands campussen</a>&nbsp;waar gewerkt wordt aan de nieuwste innovaties op het gebied van materialen, gezondheid, slimme digitale diensten en voeding</li>\n<li>Limburg is van oudsher een grote speler in de industrie.</li>\n<li>Limburg is koploper wat betreft internationaal samenwerken: Duitsland en Belgi&euml; zijn vaste partners van de meeste Limburgse bedrijven.</li>\n</ul>\n<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Id illum reprehenderit cumque placeat magni animi provident est sapiente accusamus iure deserunt, exercitationem amet officia ducimus quam perspiciatis quos aliquam libero.</p>"
            },
            "articleCategory": {
                "iv": [
                    "Blog"
                ]
            }
        },
        "created": "2020-03-30T09:04:04Z",
        "lastModified": "2020-03-31T12:13:16Z",
        "status": "Published",
        "statusColor": "#4bb958",
        "schemaName": "items",
        "schemaDisplayName": "items",
        "version": 4,
        "_links": {
            "self": {
                "href": "/api/content/app-name/items/718cfeca-789d-4843-95f8-45e513bbcac5",
                "method": "GET"
            },
            "previous": {
                "href": "/api/content/app-name/items/718cfeca-789d-4843-95f8-45e513bbcac5/3",
                "method": "GET"
            }
        }
    }
],
"statuses": [
    {
        "status": "Archived",
        "color": "#eb3142"
    },
    {
        "status": "Draft",
        "color": "#8091a5"
    },
    {
        "status": "Published",
        "color": "#4bb958"
    }
],
"_links": {
    "self": {
        "href": "/api/content/app-name/items",
        "method": "GET"
    }
}

}

What i would like to do is search an item based on its title, i can work with the id but for useablity if a visitor of the app saves a page for a single item the url will contain the title of the item so i can only do the search via the items title.

I have been trying all day to get an item with Postman to find the GET url setup i need to achieve this but i cannot get it to work.

Could anyone provide an example on how to find 1 single item based on the articleTitle of an item?
i always get an error saying there is a syntax error or that it finds 0 total items.

I tried things like:
https://cloud.squidex.io/api/content/app-name/items?$search=artikel 3 lorem ipsum dolor sit amet consectuer
https://cloud.squidex.io/api/content/app-name/items?$search=artikel_3_lorem_ipsum_dolor_sit_amet_consectuer
https://cloud.squidex.io/api/content/app-name/items?$filter=data/articleTitle/iv eq artikel 3 lorem ipsum dolor sit amet consectuer
https://cloud.squidex.io/api/content/app-name/items?$filter=data/articleTitle/iv eq artikel_3_lorem_ipsum_dolor_sit_amet_consectuer

I am not profound with using OData and the squidex docs nor any docs i can find on google is helping out.

Hi, the last example should almost work:

It should be

$filter=data/articleTitle/iv eq 'artikel 1 lorem ipsum dolor sit amet consectuer'

Btw: have you read: https://docs.squidex.io/02-documentation/developer-guides/api-overview/api

Hi Sebastian,

First of al, thanks for the uber fast reply and good to be talking to you again.
Cheers for the example and yes i have been reading that doc. But i guess that after al the trying out i ended up in tunnel vision.

To be honest i tried single quotes but i think i did that in an incorrect syntax so thats why that would not have worked.

But it works now? …

Ah yes it works now, sorry for not mentioning.
Thanks again!

1 Like