0

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 Answer 1

0

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://learn.microsoft.com/en-us/previous-versions/dynamicsnav-2016/hh169248(v=nav.90)) can be very helpful for starting with filter expressions in OData URIs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.