Skip to main content

Notifications

Community site session details

Community site session details

Session Id : ah0JIj16t3ETxeXp8SHeGS
Power Automate - Building Flows
Suggested answer

Prevent Automatic Escaping of Newline Characters in HTTP Request Body

Like (0) ShareShare
ReportReport
Posted on 14 Feb 2025 16:41:23 by

Hi guys,

I'm working with a Power Automate flow and am trying to send a private key retrieved from an Azure Key Vault in an HTTP request. However, the private key includes newline characters (represented as \n), and when I pass it through the HTTP request, Power Automate automatically escapes these newline characters (turning \n into \\n). I want to ensure that the key remains unchanged and the newlines are preserved as they are.

Example:

  • The key looks like this in the compose output: "-----BEGIN ENCRYPTED PRIVATE KEY-----\<REMOVED CONTENT>\n...".
  • After using the key in the HTTP request, it becomes "-----BEGIN ENCRYPTED PRIVATE KEY-----\\<REMOVED CONTENT>\\n...".

Steps I’ve tried:

  1. I attempted to use the replace() function to remove the backslashes:
    replace(outputs('AirhartKey')?['body/value'], '\\n', '\n'), but this doesn't seem to work.

  2. I tried passing the key directly in the HTTP request, but it still gets altered with extra backslashes.

I’ve also verified that the key is being retrieved correctly from the Azure Key Vault, but when it's used in the HTTP request, the newlines are altered. How can I prevent this transformation and send the key without it being changed?

Any help would be appreciated! Thanks!

  • Suggested answer
    David_MA Profile Picture
    10,826 Super User 2025 Season 1 on 14 Feb 2025 at 18:06:26
    Prevent Automatic Escaping of Newline Characters in HTTP Request Body
    Try this:
    • Create a string variable (EncodedKey) and then encode your value in base64 as the initial value: base64(outputs('AirhartKey')?['body/value'])
    • Then where you need to use it, convert the base64 to a string: base64ToString(variables('EncodedKey'))

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 61

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 47 Super User 2025 Season 1

#3
rzaneti Profile Picture

rzaneti 29 Super User 2025 Season 1

Overall leaderboard