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,046 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard