Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Best way to prevent forbidden characters

(1) ShareShare
ReportReport
Posted on by 260

Hello

 

I have been trouble shooting occasional errors in my flow. The user enters text in a SharePoint field and a folder is generated after that. 

It had been giving me BadRequests, but a trim operation removed any trailing spaces and it worked great, until it the issue started again.

As it turns out there are also forbidden characters, (:, /, ...) being used.

 

I naturally think a replace operation could screen out the characters, but it would be a mess. Is there a more elegant solution?

 

Regards

Conn

  • trice602 Profile Picture
    13,773 Super User 2025 Season 1 on at
    Re: Best way to prevent forbidden characters

    Hi @ConnM !  Nice!  Always glad to help and get this feedback on a Monday morning 🙂 

     

     

  • ConnM Profile Picture
    260 on at
    Re: Best way to prevent forbidden characters

    Thanks @trice602 

     

    This is brilliant. I'll get this in ASAP

     

    Really appreciate it

    Conn

     

  • trice602 Profile Picture
    13,773 Super User 2025 Season 1 on at
    Re: Best way to prevent forbidden characters

    Note:  you would replace "test" above with your dynamic content.

     

     

  • Verified answer
    trice602 Profile Picture
    13,773 Super User 2025 Season 1 on at
    Re: Best way to prevent forbidden characters

    Hi @ConnM ,

     

    One thing that I have done is insert a compose and replace the illegal characters with an "_" or remove it completely.  Here's a sample replace expression to remove the most common characters:

    replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(test, '\\', ''), '/', ''), ':', ''), '*', ''), '?', ''), '"', ''), '<', ''), '>', ''), '|', ''), '&', ''), '#', '')

     

     

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492