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

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Passing HTML content as a variable to build a JSON

(0) ShareShare
ReportReport
Posted on by 143

Dear community, I'm trying to pass a rich text content, effectively HTML text, between flows. First flow gets the content as a formatted text, puts it into a variable and then uses this variable to build a JSON that is then POSTed to another flow via HTTP call. The pseudo code would look like this: set varMyRichText = links > set varMyJSON = { "RichTextVar" : "variables('varMyRichText')"} Now when I look at the content of the varMyJSON it gets all confused because it messes up the quotes found inside original rich text like those that are part of hyperlinks, with the quotes that come around "value" in the JSON. I could probably map all the special chars to their ascii codes in an set of extra steps, but is there any better way to just pass the "rich text" content around? Thank you,

I have the same question (0)
  • v-litu-msft Profile Picture
    on at
    Re: Passing HTML content as a variable to build a JSON

    Hi @in2217

     

    You can store these HTML text stored as an HTML file in a SharePoint folder, then store the link into the JSON object.

    There is a document about the portable text, I hope it can help you:

    https://github.com/portabletext/portabletext

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • in2217 Profile Picture
    143 on at
    Re: Passing HTML content as a variable to build a JSON

    Hi @v-litu-msft,

     

     

     

     

     

  • Verified answer
    in2217 Profile Picture
    143 on at
    Re: Passing HTML content as a variable to build a JSON

    Hi,

    update with solution here.

     

    Looking closer at what causes the problem, I found that it was only double quote sign ( " ) that ruined JSON as it would collide with the quotes in the syntax of the JSON:

    {

    "key" : "$value"

    }

     

    So I've run the value through "replace" function before adding it to the JSON. Like this:

     

    replace(variables('value'), '"', '"')

     

    (ASCII code for double quote is ")

     

    This was it.

    No need to translate it back on receiving end.

     

    I'll remember to translate the double quotes in the rich text / html texts whenever I'll need to pass it over to another flow or otherwise use it inside a JSON.

  • ricoc137 Profile Picture
    6 on at
    Re: Passing HTML content as a variable to build a JSON

    @in2217 Hey I was stuck on this problem for days and your replace function method helped me get past that problem although the email body in html that I am converting to JSON for the http post request to work is not being formatted correctly once displayed in Outlook. Wondering if you ran into similar issue and had found any solution?

     

    Thanks,

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 647 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 350 Moderator

#3
developerAJ Profile Picture

developerAJ 256

Last 30 days Overall leaderboard