Create an array from the output of POST request in JSON Object
Here is how it worked for me:
Taking provided JSON into consideration Instead of having body as From data in Create HTML table I have used data
since the Create HTML table takes only array as input and then modified the same while sending the email.
Here is my Logic app :
Here is the email :
Updated Answer
Here is the whole logic app
For parse JSON I'm generating the schema using sample payload with the same JSON that you have provided with sample values. i.e..
{
"body": {
"totalRecords": 25,
"count": 25,
"data": [
{
"id": "SampleId",
"diskState": "Sample",
"resourceGroup": "dkfdfjsi",
"location": "gareg",
"subscriptionId": "fgser"
},
{
"id": "SampleID2",
"diskState": "SAmple2",
"resourceGroup": "dkfdfjsi",
"location": "gareg",
"subscriptionId": "fgser"
}
]
}
}
As your requirement is to send the data in a tabular format I have used the same connector as you did i.e. Create HTML Table
with data
array as input to the connector and so it will be generating the table automatically with the headers in the format mentioned below
Lastly, I have used the output of the HTML Table connector to send the email
Here is the code view of my logic app
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Create_HTML_table_2": {
"inputs": {
"format": "HTML",
"from": "@body('Parse_JSON')?['body']?['data']"
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "Table"
},
"Parse_JSON": {
"inputs": {
"content": "@triggerBody()",
"schema": {
"properties": {
"body": {
"properties": {
"count": {
"type": "integer"
},
"data": {
"items": {
"properties": {
"diskState": {
"type": "string"
},
"id": {
"type": "string"
},
"location": {
"type": "string"
},
"resourceGroup": {
"type": "string"
},
"subscriptionId": {
"type": "string"
}
},
"required": [
"id",
"diskState",
"resourceGroup",
"location",
"subscriptionId"
],
"type": "object"
},
"type": "array"
},
"totalRecords": {
"type": "integer"
}
},
"type": "object"
}
},
"type": "object"
}
},
"runAfter": {},
"type": "ParseJson"
},
"Send_an_email_(V2)_2": {
"inputs": {
"body": {
"Body": "<p><strong>Total Records</strong> :@{body('Parse_JSON')?['body']?['totalRecords']} , <strong>Count </strong>: @{body('Parse_JSON')?['body']?['count']}<br>\n-----------------------------------------------------------------------------<br>\n@{body('Create_HTML_table_2')}</p>",
"Subject": "Sample Test",
"To": "<YOUR REQUIRED EMAIL ID>"
},
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {
"Create_HTML_table_2": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"manual": {
"inputs": {},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {
"$connections": {
"value": {
"office365": {
"connectionId": "/subscriptions/<YOUR SUBSCRIPTION ID>/resourceGroups/<YOUR RESOURCE GROUP>/providers/Microsoft.Web/connections/office365",
"connectionName": "office365",
"id": "/subscriptions/<YOUR SUBSCRIPTION ID>/providers/Microsoft.Web/locations/northcentralus/managedApis/office365"
}
}
}
}
}