3

I want to add a JSON message as a value in the other JSON message in Microsoft Power Automate.

In more details, I have a flow that is storing a JSON message in Azure Queue storage. This message will be parsed by another flow which is sending an email. However, one of the attributes of the JSON is the email body. I want to put in the email body value, another JSON message.

What I have tried was to escape all JSON characters of the Email body with the following way

@{replace(replace(variables('emailBody'),'/','\/'),'"','\"')}

but it does not always work.

I have also tried to use the method string.encodeUriComponent which is also not nice because the message I receive is unreadable.

JSON message to send emails

{
    "To": "recipient@domain.ext",
    "Subject": "emailSubject",
    "Body": "emailBody",
    "From":"sender@domain.ext",
    "CC": "ccedreceipient@domain.ext",
    "Importance": "Normal",
    "Is HTML": false
}

Example of the emailBody string (emailbody):

{ 
   "Error":{ 
      "Code":0,
      "Message":"",
      "ErrorCode":"",
      "FailureType":""
   },
   "Status":"Succeeded",
   "Duration":null,
   "ActivityRunId":"idddididididididididididi",
   "Output":"{\"pipelineName\":\"E2E Pipeline\",\"pipelineRunId\":\"ididididididi\"}",
   "ExecutionStartTime":"2018-09-23T19:00:04.3644468Z",
   "ExecutionEndTime":"2018-09-24T02:42:32.9746196Z",
   "StatusCode":200
}

Is there any method in Microsoft Power Automate to make a sting a valid JSON value, so that I can put the email body string as a value in the Body attribute of the first JSON message?

TylerH
  • 20,799
  • 66
  • 75
  • 101
aragorn
  • 187
  • 3
  • 18

0 Answers0