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 output string v...
Power Automate
Answered

how to output string value out of json parse ?

(0) ShareShare
ReportReport
Posted on by 40

expressionevaluationfailed.PNGhi,

 

i have an issue to output a value . Example below is the output. I need to get the 1st media_type = ' image/jpeg" out of this. 

{
"images": [
{
"id": "875871070",
"download_sizes": [
{
"bytes": 69498,
"height": 416,
"media_type": "image/jpeg",
"name": "x_small",
"width": 416
},
{
"bytes": 109213,
"height": 594,
"media_type": "image/jpeg",
"name": "small",
"width": 594
},
{
"bytes": 375336,
"height": 1735,
"media_type": "image/jpeg",
"name": "medium",
"width": 1735
},
{
"bytes": 1255700,
"height": 4000,
"media_type": "image/jpeg",
"name": "large",
"width": 4000
},
{
"bytes": 12135563,
"height": 4000,
"media_type": "image/eps",
"name": "vector",
"width": 4000
}
]
}
],
"images_not_found": []
}

 

below is my json :

{
"type": "object",
"properties": {
"image": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"download_sizes": {
"type": "object",
"properties": {
"bytes": {
"type": "string"
},
"height": {
"type": "string"
},
"media_type": {
"type": "string"
},
"name": {
"type": "string"
},
"width": {
"type": "string"
}
}
}
}
}
}
}
}

 

this is the error message i got when trying to output the 'image/jpeg'  :

ExpressionEvaluationFailed. The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@body('ParseFindMediaType')?['image']' is of type 'Null'. The result must be a valid array.

 

Please advice and thanks in advance

Categories:
I have the same question (0)
  • Verified answer
    v-litu-msft Profile Picture
    Microsoft Employee on at

    Hi @vnguyen1,

     

    The property name in the Apply to each input should be body('Parse_JSON')?['images'], not body('Parse_JSON')?['image'], and the stcuture as below:

    Screenshot 2021-02-24 142820.jpg

     

    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.

  • vnguyen1 Profile Picture
    40 on at

    Thanks @v-litu-msft  for the response. however, i still got the same error message either (1) or (2). Please advice

     

    vnguyen1_2-1614149401088.png

     

    (1)

    vnguyen1_3-1614149449826.png

     

    (2)

     

    vnguyen1_1-1614149309693.png

     

  • v-litu-msft Profile Picture
    Microsoft Employee on at

    Hi @vnguyen1,

     

    It is images, not image:

    Screenshot 2021-02-24 142820.jpg

     

    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.

  • vnguyen1 Profile Picture
    40 on at

    @v-litu-msft i got below error when update image to images in jason.Please advice

     

    {
      "type""object",
      "properties": {
        "images": {
          "type""array",
          "items": {
            "images_not_found": {
              "type""object",
              "properties": {}
            },
            "type""object",
            "properties": {
              "id": {
                "type""string"
              },
              "download_sizes": {
                "type""object",
                "properties": {
                  "bytes": {
                    "type""string"
                  },
                  "height": {
                    "type""string"
                  },
                  "media_type": {
                    "type""string"
                  },
                  "name": {
                    "type""string"
                  },
                  "width": {
                    "type""string"
                  }
                }
              }
            },
            "required": [
              "media_type",
              "id"
            ]
          }
        }
      }
    }

     

    vnguyen1_0-1614150181488.png

    [
      {
        "message""Invalid type. Expected Object but got Array.",
        "lineNumber"0,
        "linePosition"0,
        "path""images[0].download_sizes",
        "schemaId""#/properties/images/items/properties/download_sizes",
        "errorType""type",
        "childErrors": []
      },
      {
        "message""Required properties are missing from object: media_type.",
        "lineNumber"0,
        "linePosition"0,
        "path""images[0]",
        "value": [
          "media_type"
        ],
        "schemaId""#/properties/images/items",
        "errorType""required",
        "childErrors": []
      }
    ]
  • vnguyen1 Profile Picture
    40 on at

    @v-litu-msft below is how i set it up and got the error in jason.Please advice

     

    [
      {
        "message""Invalid type. Expected Object but got Array.",
        "lineNumber"0,
        "linePosition"0,
        "path""images[0].download_sizes",
        "schemaId""#/properties/images/items/properties/download_sizes",
        "errorType""type",
        "childErrors": []
      },
      {
        "message""Required properties are missing from object: media_type.",
        "lineNumber"0,
        "linePosition"0,
        "path""images[0]",
        "value": [
          "media_type"
        ],
        "schemaId""#/properties/images/items",
        "errorType""required",
        "childErrors": []
      }
    ]

    vnguyen1_2-1614151098999.png

     

  • v-litu-msft Profile Picture
    Microsoft Employee on at

    Hi @vnguyen1,

     

    Please try to use the JSON schema:

    {
     "type": "object",
     "properties": {
     "images": {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "id": {
     "type": "string"
     },
     "download_sizes": {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "bytes": {
     "type": "integer"
     },
     "height": {
     "type": "integer"
     },
     "media_type": {
     "type": "string"
     },
     "name": {
     "type": "string"
     },
     "width": {
     "type": "integer"
     }
     },
     "required": [
     "bytes",
     "height",
     "media_type",
     "name",
     "width"
     ]
     }
     }
     },
     "required": [
     "id",
     "download_sizes"
     ]
     }
     },
     "images_not_found": {
     "type": "array"
     }
     }
    }

     

    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.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 468

#2
Haque Profile Picture

Haque 370

#3
Valantis Profile Picture

Valantis 354

Last 30 days Overall leaderboard