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 / How to parse and use t...
Power Automate
Answered

How to parse and use the JSON data that is sent by webhook to a teams channel?

(1) ShareShare
ReportReport
Posted on by 12

 

 

Dear all

I am at a loss and need help.

I try to send a webhook (with JSON data) from an external source to a teams channel. It works as I do get a message in the teams channel from the external source, however, I can't parse and use the JSON data trasmitted (to post it in the teams channel message).

The interesting data I want to use in the teams message is in the body/text object in the webhook - and optimally I would like to use the different objects within said data to design a message into the teams channel.
But I can't even put the whole JSON line in the message to begin with (let alone parse it for the individual pieces of information, which is the goal I am striving for).

Can you help me figure out what I am missing?

My Flow:

See attached file

My JSON configuration/data (somewhat obfuscated):

The original JSON info from the webhook (the "body" being the interesting part for me):

{
    "headers": {
        "Accept": "*/*",
        "Host": "obfuscated",
        "Max-Forwards": "10",
        "X-ARR-LOG-ID": "obfuscated",
        "CLIENT-IP": "obfuscated",
        "DISGUISED-HOST": "obfuscated",
        "X-SITE-DEPLOYMENT-ID": "obfuscated",
        "WAS-DEFAULT-HOSTNAME": "obfuscated",
        "X-Forwarded-Proto": "https",
        "X-AppService-Proto": "https",
        "X-ARR-SSL": "obfuscated",
        "X-Forwarded-TlsVersion": "1.3",
        "X-Forwarded-For": "obfuscated",
        "X-Original-URL": "obfuscated",
        "X-WAWS-Unencoded-URL": "obfuscated",
        "Content-Length": "194",
        "Content-Type": "application/json"
    },
    "body": {
        "text": "<pre>{\n \"content\": \"obfuscated\".\n \"message\": \"\",\n \"time\": \"%%log_time%%\",\n \"username\": \"%%log_user%%\",\n \"source IP\": \"%%log_srcip%%\"\n}</pre>"
    }
}
 
The JSON information in the "parse JSON" action:
 
raw inputs:
{
    "content": {
        "text": "<pre>{\n \"content\": \"obfuscated\".\n \"message\": \"\",\n \"time\": \"%%log_time%%\",\n \"username\": \"%%log_user%%\",\n \"source IP\": \"%%log_srcip%%\"\n}</pre>"
    },
    "schema": {
        "type": "object",
        "properties": {
            "content": {
                "type": "string"
            },
            "message": {
                "type": "string"
            },
            "time": {
                "type": "string"
            },
            "username": {
                "type": "string"
            },
            "source IP": {
                "type": "string"
            }
        }
    }
}


raw ouputs:
{
    "body": {
        "text": "<pre>{\n \"content\": \"obfuscated\".\n \"message\": \"\",\n \"time\": \"%%log_time%%\",\n \"username\": \"%%log_user%%\",\n \"source IP\": \"%%log_srcip%%\"\n}</pre>"
    }
}
 
 
flow1_obfuscated.png
Categories:
I have the same question (0)
  • Suggested answer
    SwatiSTW Profile Picture
    807 Super User 2026 Season 1 on at
    The problem is that the JSON you want is inside a string field called text, and it includes <pre> tags. So Power Automate can't directly parse it. You need to extract that string, clean it, and parse it again.
    1. First Parse JSON to extract the text field from the incoming webhook
    Schema to use:
        {
          "type": "object",
          "properties": {
            "text": {
              "type": "string"
            }
          }
        }
    2. Add a Compose action to remove <pre> and </pre> from the text
    Expression to use:
        replace(replace(body('Parse_JSON')?['text'], '<pre>', ''), '</pre>', '')
    3. Add a second Parse JSON action, use output from the Compose as input
    Content field:
        outputs('Compose')
    Schema to use:
        {
          "type": "object",
          "properties": {
            "content": { "type": "string" },
            "message": { "type": "string" },
            "time": { "type": "string" },
            "username": { "type": "string" },
            "source IP": { "type": "string" }
          }
        }
    4. In the Teams message action, use dynamic content from the second Parse JSON
    Example message:
        <b>New Log Entry</b><br>
        User: @{outputs('Parse_JSON_2')?['username']}<br>
        Message: @{outputs('Parse_JSON_2')?['message']}<br>
        Time: @{outputs('Parse_JSON_2')?['time']}<br>
        Source IP: @{outputs('Parse_JSON_2')?['source IP']}
    This will show each field correctly in the Teams message.
  • SS-03041020-0 Profile Picture
    12 on at
     
    Thank you very much for your reply and your advice - thanks to you I am several steps further.
    Unfortunately, I am still making a mistake along the path as now the second "parse json" fails.
     
    In the "componse" action I only have one single configuration available, which is called "inputs". I put in the expression you mentioned = replace(replace(body('Parse_JSON')?['text'], '<pre>', ''), '</pre>', '').
    However, I have the feeling this wasn't correct on my part.
     
    The error message now reads:
     
    InvalidJSON. The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value cannot be parsed: 'Unexpected character encountered while parsing value: o. Path '', line 0, position 0.'.
     
     
    And the raw output of the "compose" action reads as follows:
     
    "replace(replace(body('Parse_JSON')?['text'], '<pre>', ''), '</pre>', '')"
     
    Do you have any advice?
     
     
    P.S.:
    The output of the first "parse json" looks extremly promising:
    <pre>{
    "content": "obfuscate".
    "message": "",
    "time": "%%log_time%%",
    "username": "%%log_user%%",
    "source IP": "%%log_srcip%%"
    }</pre>
     
  • Chriddle Profile Picture
    8,672 Super User 2026 Season 1 on at
    The JSON within the property "text" is invalid.
    Assuming it is an editing error and after cleaning:
     
     
    Compose: The original JSON
     
    Parse JSON:
    Content:
    json(
    	slice(
    		body('Compose')['text'],
    		5,
    		-6
    	)
    )
    Schema:
    {
        "type": "object",
        "properties": {
            "content": {
                "type": "string"
            },
            "message": {
                "type": "string"
            },
            "time": {
                "type": "string"
            },
            "username": {
                "type": "string"
            },
            "source IP": {
                "type": "string"
            }
        }
    }
     
     
  • SS-03041020-0 Profile Picture
    12 on at
    Dear @Chriddle and @SwatiSTW
     
    As suggested by @Chriddle I added another "parse json" action after the "compose" action with the configuraiton that was suggested and with the following result (raw input):
     
    {
        "content": "json(\n\tslice(\n\t\tbody('Compose')['text'],\n\t\t5,\n\t\t-6\n\t)\n)",
        "schema": {
            "type": "object",
            "properties": {
                "content": {
                    "type": "string"
                },
                "message": {
                    "type": "string"
                },
                "time": {
                    "type": "string"
                },
                "username": {
                    "type": "string"
                },
                "source IP": {
                    "type": "string"
                }
            }
        }
    }
     
     
    While I was able to save that flow in power automate, it now gives me the following error message when the flow is triggered:
     
    InvalidJSON
    The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value cannot be parsed: 'Unexpected character encountered while parsing value: j. Path '', line 0, position 0.'.
     
    It appears that the "content" part of the second "parse json" can't be a json slice operation? Or am I missing some special flag needed for the slice json operation to be valid in the "content" part of the "parse json" action?
     
    Again, the output of the compose is promising (it just has the <pre> tags still in it):
     
     
    "<pre>{\n \"content\": \"AdminLogin on Fortigate\".\n \"message\": \"\",\n \"time\": \"%%log_time%%\",\n \"username\": \"%%log_user%%\",\n \"source IP\": \"%%log_srcip%%\"\n}</pre>"
     
     
  • Verified answer
    Chriddle Profile Picture
    8,672 Super User 2026 Season 1 on at
    The problem is that the text isn't valid JSON.
    Instead of a comma, there's a period.
     
    I fixed this in advance in last week's proposed solution.
     
     
    Can you fix the input?
  • SS-03041020-0 Profile Picture
    12 on at
     
    Please accept my sincere apologies - you are absolutely right and I have missed that in your post.
     
    I corrected the input (I indeed made a typo - should have been a comma) and from there things look amazingly better with all your input.
     
    Thanks to you I am busy with finetuning, but not with troubleshooting anymore.
     
    To all, thanks a lot for your help - it is very much appreciated

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
Haque Profile Picture

Haque 607

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard