I am making one API call in Power Automate and the response I am receiving the below JSON
{
"paging": {
"start": 0,
"count": 10,
"links": [],
"total": 3
},
"elements": [
{
"isReshareDisabledByAuthor": false,
"createdAt": 1704446818959,
"lifecycleState": "PUBLISHED",
"lastModifiedAt": 1704446818959,
"visibility": "PUBLIC",
"publishedAt": 1704446818959,
"author": "urn:li:organization:101414444",
"id": "urn:li:share:7148968102884841984",
"distribution": {
"feedDistribution": "MAIN_FEED",
"thirdPartyDistributionChannels": []
},
"content": {
"media": {
"altText": "",
"id": "urn:li:image:D4D22AQHbdiWdPzeHtg"
}
},
"commentary": "Hi Test",
"lifecycleStateInfo": {
"isEditedByAuthor": false
}
},
{
"isReshareDisabledByAuthor": false,
"createdAt": 1704285674051,
"lifecycleState": "PUBLISHED",
"lastModifiedAt": 1704285674096,
"visibility": "PUBLIC",
"publishedAt": 1704285674051,
"author": "urn:li:organization:101414444",
"id": "urn:li:ugcPost:7148292213186180096",
"distribution": {
"feedDistribution": "MAIN_FEED",
"thirdPartyDistributionChannels": []
},
"content": {
"multiImage": {
"images": [
{
"altText": "",
"id": "urn:li:image:D4D22AQFnjGKot4DBIg"
},
{
"altText": "",
"id": "urn:li:image:D4D22AQEzSmXKu93lmw"
},
{
"altText": "",
"id": "urn:li:image:D4D22AQGMb7DQf3s7zA"
}
]
}
},
"commentary": "Hi There",
"lifecycleStateInfo": {
"isEditedByAuthor": false
}
},
{
"isReshareDisabledByAuthor": false,
"lifecycleState": "PUBLISHED",
"createdAt": 1703744862033,
"lastModifiedAt": 1703744862095,
"visibility": "PUBLIC",
"publishedAt": 1703744862033,
"author": "urn:li:organization:101414444",
"id": "urn:li:share:7146023559452666882",
"distribution": {
"feedDistribution": "MAIN_FEED",
"thirdPartyDistributionChannels": []
},
"commentary": "Hi Community!",
"lifecycleStateInfo": {
"isEditedByAuthor": false
}
}
]
}
In my next step, I am using Parse JSON to read the above JSON like
In the Schema input of the above image, I tried to generate from the sample and it asked sample payload, where I put the above JSON and it generated the below Schema.
{
"type": "object",
"properties": {
"paging": {
"type": "object",
"properties": {
"start": {
"type": "integer"
},
"count": {
"type": "integer"
},
"links": {
"type": "array"
},
"total": {
"type": "integer"
}
}
},
"elements": {
"type": "array",
"items": {
"type": "object",
"properties": {
"isReshareDisabledByAuthor": {
"type": "boolean"
},
"createdAt": {
"type": "integer"
},
"lifecycleState": {
"type": "string"
},
"lastModifiedAt": {
"type": "integer"
},
"visibility": {
"type": "string"
},
"publishedAt": {
"type": "integer"
},
"author": {
"type": "string"
},
"id": {
"type": "string"
},
"distribution": {
"type": "object",
"properties": {
"feedDistribution": {
"type": "string"
},
"thirdPartyDistributionChannels": {
"type": "array"
}
}
},
"content": {
"type": "object",
"properties": {
"media": {
"type": "object",
"properties": {
"altText": {
"type": "string"
},
"id": {
"type": "string"
}
}
}
}
},
"commentary": {
"type": "string"
},
"lifecycleStateInfo": {
"type": "object",
"properties": {
"isEditedByAuthor": {
"type": "boolean"
}
}
}
},
"required": [
"isReshareDisabledByAuthor",
"createdAt",
"lifecycleState",
"lastModifiedAt",
"visibility",
"publishedAt",
"author",
"id",
"distribution",
"commentary",
"lifecycleStateInfo"
]
}
}
}
}
It is successfully running when content object has media value like
but it is failing when content object has multiImage value like
so, I am not sure if we can generate a Schema for the above JSON or not? or any other way to solve the above problem.
I think this should work...
{
"type": "object",
"properties": {
"paging": {
"type": "object",
"properties": {
"start": {
"type": "integer"
},
"count": {
"type": "integer"
},
"links": {
"type": "array"
},
"total": {
"type": "integer"
}
}
},
"elements": {
"type": "array",
"items": {
"type": "object",
"properties": {
"isReshareDisabledByAuthor": {
"type": "boolean"
},
"createdAt": {
"type": "integer"
},
"lifecycleState": {
"type": "string"
},
"lastModifiedAt": {
"type": "integer"
},
"visibility": {
"type": "string"
},
"publishedAt": {
"type": "integer"
},
"author": {
"type": "string"
},
"id": {
"type": "string"
},
"distribution": {
"type": "object",
"properties": {
"feedDistribution": {
"type": "string"
},
"thirdPartyDistributionChannels": {
"type": "array"
}
}
},
"content": {
"type": "object",
"properties": {
"media": {
"type": "object",
"properties": {
"altText": {
"type": "string"
},
"id": {
"type": "string"
}
}
},
"multiImage": {
"type": "object",
"properties": {
"images": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"altText": {
"type": "string"
},
"id": {
"type": "string"
}
}
}
]
}
}
}
}
},
"commentary": {
"type": "string"
},
"lifecycleStateInfo": {
"type": "object",
"properties": {
"isEditedByAuthor": {
"type": "boolean"
}
}
}
},
"required": [
"isReshareDisabledByAuthor",
"createdAt",
"lifecycleState",
"lastModifiedAt",
"visibility",
"publishedAt",
"author",
"id",
"distribution",
"commentary",
"lifecycleStateInfo"
]
}
}
}
}