davidvera
davidvera

Reputation: 1499

Graph API search by metadata / column value

I'm developping an application using MS Graph API on a sharepoint site. I'm trying to build the URL that allow me to find a drive item in a library with a colum param.

Actually I built this get URL to retrieve the drive items in the library:

https://graph.microsoft.com/v1.0/sites/{mainSite}:/sites/{subsite}:/lists/{libname}/items

I obtain a JSON with all files.

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.list)('myLib')/items",
    "value": [
    ...

        {
            "@odata.etag": "\"7773c0de-bed1-425b-9065-2310c600757b,6\"",
            "createdDateTime": "2019-11-21T09:19:57Z",
            "eTag": "\"7773c0de-bed1-425b-9065-2310c600757b,6\"",
            "id": "24",
            "lastModifiedDateTime": "2020-05-27T09:09:05Z",
            "webUrl": "https://xxxx.sharepoint.com/sites/SUBSITE/myLib/Cartouche.docx",
            "createdBy": {
                "user": {
                    "email": "[email protected]",
                    "id": "5fe24d57-1357-4fef-9cae-bfd79b0bf831",
                    "displayName": "David Vera"
                }
            },
            "lastModifiedBy": {
                "user": {
                    "email": "[email protected]",
                    "id": "5fe24d57-1357-4fef-9cae-bfd79b0bf831",
                    "displayName": "David Vera"
                }
            },
            "parentReference": {
                "id": "1836034d-8a35-4488-995e-a7fe9cd30b4c",
                "siteId": "xxx.sharepoint.com,82a2327c-e2cf-4d30-b529-31c3bcdcda5e,fbi3zrs9-b07a-4777-945b-3b42c5c876d"
            },
            "contentType": {
                "id": "0x010100E4AD49D3A8873645A2803D49D2A4BF60"
            }
        },
    ...
    ]
}

enter image description here

I tried to use filter :

https://graph.microsoft.com/v1.0/sites/{mainSite}:/sites/{subsite}:/lists/{libname}/items?expand=fields(select=CODE_ANNONCEUR,val)&filter=fields/val eq 'myself'

It returns me :

{
    "error": {
        "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
        "message": "The expression « fields (select ») is not valid.",
        "innerError": {
            "request-id": "c3edc510-2d63-4f21-86cd-a377fb02d324",
            "date": "2020-05-27T09:44:23"
        }
    }
}

Upvotes: 0

Views: 1495

Answers (1)

davidvera
davidvera

Reputation: 1499

I solved the issue this way :

https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com:/sites/yyy:/lists/zzz/items?expand=fields/CODE_ANNONCEUR&filter=fields/CODE_ANNONCEUR eq 'stringExpected'

Upvotes: 1

Related Questions