0
votes

I am trying to retrieve folders in a sharepoint list where folder name starts with

https://**.sharepoint.com/_api/Web/GetFolderByServerRelativePath(decodedurl='/Salesforce')/Folders?$filter=Name startswith ‘abc’

error

{ "error": { "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException", "message": { "lang": "en-US", "value": "The expression \"Name startswith ‘abc’\" is not valid." } } }

https://**.sharepoint.com/_api/Web/GetFolderByServerRelativePath(decodedurl='/Salesforce')/Folders?$select=Name$filter=contains(Name,'abc')

{ "error": { "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException", "message": { "lang": "en-US", "value": "The expression \"Name$filter=contains(Name,'abc')\" is not valid." } } }

Please guide.

Sorry had to add &

https://****.sharepoint.com/_api/Web/GetFolderByServerRelativePath(decodedurl='/Salesforce')/Folders?$select=Name&$filter=((startswith(name,'test')))

now it is returning all folders. not the one that are started with test

1

1 Answers

0
votes

The 'startwith' filter has the following format:

$filter=startswith(FieldName, 'abc')

And if you need to use the 'contains' filter you have to use the following format:

$filter=substringof(FieldName, 'abc')

This article (https://docs.microsoft.com/en-us/previous-versions/dynamicsnav-2016/hh169248(v=nav.90)) can be very helpful for starting with filter expressions in OData URIs.