web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / OData $filter fails wh...
Power Automate
Answered

OData $filter fails when FileLeafRef contains an apostrophe ' — how to escape properly?

(0) ShareShare
ReportReport
Posted on by 55

Hello everyone,

I’m running into an issue when using Get files (properties only) in Power Automate to retrieve a specific SharePoint folder by its name.

The folder name contains an apostrophe (').

Example pattern:  Something l'emploi

I’m using this OData filter:

ContentType eq 'Folder' and FileLeafRef eq 'Something l'emploi'

This fails with: The file or folder cannot be found.

I tried escaping the apostrophe (as required by OData) like this:

ContentType eq 'Folder' and FileLeafRef eq 'Something l''emploi'

But the query still does not match the folder, even though the folder does exist.

Other tests:

  • Removing the filter works (it returns all folders)

  • Filtering on names with no apostrophes works

  • The issue happens only when an apostrophe is in the folder name

  • Using substringof() also fails when the value contains '

My Question

Is there a correct or supported way to filter FileLeafRef values that contain an apostrophe using the SharePoint connector OData $filter?

Or is this a known limitation of the SharePoint connector?

I would appreciate any insight or examples.

Thanks!



 

 "body": {
        "status"400,
        "message""The expression \"ContentType eq 'Folder' and FileLeafRef eq 'pour l'emploi'\" is not valid. Creating query failed.\r\nclientRequestId: 418a25d1-f5ae-40ab-997e-81b9951dfe10\r\nserviceRequestId: 855ddaa1-50da-a000-7f85-05d3235e677b"
    }
}
Categories:
I have the same question (0)
  • Verified answer
    Ellis Karim Profile Picture
    11,723 Super User 2025 Season 2 on at
     
    Your query is almost correct. I think the query needs to be:
     FSObjType eq 1  and FileLeafRef eq 'Something l''emploi'
    FSObjType eq 1 will return Folders only and any folder or file names with apostrophes must use two apostrophes instead of one:
     
     
    In the expression below we take the folder name and double any apostrophes so that it is safe to use in an OData filter query:
    replace(variables('varFolderName'),'''','''''')
    The expression above looks messy because of how Power Automate escapes apostrophes. Text values are wrapped in single quotes, and a real apostrophe inside that text is written by doubling it. So, in practice:
     
    ''''   = one apostrophe  (')
    '''''' = two apostrophes ('')
     
     
    Ellis Karim
    Ellis Karim
    elliskarim.com  |  LinkedIn  |  Bluesky
    If this solved your issue, please mark it as ✅ Accepted Answer. If it helped, feel free to give it a 🩷 Like!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 441 Super User 2025 Season 2

#2
developerAJ Profile Picture

developerAJ 145

#3
David_MA Profile Picture

David_MA 140 Super User 2025 Season 2

Last 30 days Overall leaderboard