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

Announcements

News and Announcements icon
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 59

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
    12,163 Super User 2026 Season 1 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard