I'm having a hard time figuring out how to query my Document Library in SharePoint. It just seems to return random files.
I need to search a Document Library by filename and return the files found plus a few custom columns, lets call them ColumnA and ColumnB.
My Document Library
I should mention that my site is called test site and my library is called test.
I've tried:
/v1.0/drives/{drive-id}/search(q='name:test')
Returns:
12345
54321
/v1.0/drives/{drive-id}/search(q='test')
Returns:
all files
/v1.0/drives/{drive-id}/search(q='name:dummy')
Returns:
none
/v1.0/drives/{drive-id}/search(q='dummy')
Returns:
dummy
Okay... so search doesn't do what I want as I cannot limit it to only search in the name property. Also I cannot $expand=fields
as that'll result in Parsing Select and Expand failed.
and I need to include ColumnA and ColumnB in the result.
So I tried
/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=fields&$filter=startswith(fields/LinkFilename, 'test')
Returns
Field 'LinkFilename' cannot be referenced in filter or orderby as it is not indexed.
I do not want to create indexes nor do I want to use the unsafe Prefer: HonorNonIndexedQueriesWarningMayFailRandomly
header.
So I tried
/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=fields,driveItem&$filter=startswith(driveItem/name, 'test')
Returns
An unspecified error has occurred.
Any suggestions?