Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Cannot Parse JSON - The result must be a valid array.

(0) ShareShare
ReportReport
Posted on by

Hi All

 

I am having issues trying to parse a JSON then store the data in a sql table. Would really appreciate some help on this one.

Error below:
The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['body']?['employees']' is of type 'Null'. The result must be a valid array.

My JSON Schema:

 

{
 "type": "object",
 "properties": {
 "body": {
 "type": "object",
 "properties": {
 "title": {
 "type": "string"
 },
 "fields": {
 "type": "array",
 "items": {
 "type": "object",
 "properties": {
 "id": {
 "type": "string"
 },
 "type": {
 "type": "string"
 },
 "name": {
 "type": "string"
 }
 },
 "required": [
 "id",
 "type",
 "name"
 ]
 }
 },
 "employees": {
 "type": "array",
 "items": {
 "type": "object",
 "properties": {
 "91": {
 "type": "string"
 },
 "id": {
 "type": "string"
 },
 "employeeNumber": {
 "type": "string"
 },
 "firstName": {
 "type": "string"
 },
 "lastName": {
 "type": "string"
 },
 "jobTitle": {
 "type": "string"
 },
 "customCultureManager2": {},
 "customTeamName": {},
 "photoUploaded": {
 "type": "boolean"
 },
 "photoUrl": {
 "type": "string"
 }
 },
 "required": [
 "91",
 "id",
 "employeeNumber",
 "firstName",
 "lastName",
 "jobTitle",
 "customCultureManager2",
 "customTeamName",
 "photoUploaded",
 "photoUrl"
 ]
 }
 }
 }
 },
 "statusCode": {
 "type": "integer"
 },
 "headers": {
 "type": "object",
 "properties": {
 "Transfer-Encoding": {
 "type": "string"
 },
 "Connection": {
 "type": "string"
 },
 "Pragma": {
 "type": "string"
 },
 "Strict-Transport-Security": {
 "type": "string"
 },
 "Vary": {
 "type": "string"
 },
 "X-Content-Type-Options": {
 "type": "string"
 },
 "Cache-Control": {
 "type": "string"
 },
 "Date": {
 "type": "string"
 },
 "Server": {
 "type": "string"
 },
 "Content-Type": {
 "type": "string"
 },
 "Expires": {
 "type": "string"
 },
 "Content-Length": {
 "type": "string"
 }
 }
 }
 }
}

 

 

 



therush321_0-1636727224672.png

 

  • dsab81 Profile Picture
    Microsoft Employee on at
    Re: Cannot Parse JSON - The result must be a valid array.

    This one below worked for me . Thanks @Expiscornovus 

     

    outputs('Parse_JSON')?['body']?['employees']

     

  • tandey Profile Picture
    6 on at
    Re: Cannot Parse JSON - The result must be a valid array.

    @body('Parse_JSON')['employees'] is the input to foreach and it will work

  • jguthrie25414 Profile Picture
    2 on at
    Re: Cannot Parse JSON - The result must be a valid array.

    Any idea on what might be causing the double 'body' in parsing?  I am having the same issue with a whole other dataset.  I can get it to parse using your expression above, but it still won't let me do anything with it after that.  Keeps wanting to embed new commands in another Apply to Each command.

  • therush321 Profile Picture
    on at
    Re: Cannot Parse JSON - The result must be a valid array.

    @Expiscornovus  Thank you very much.

    I changed the expression for the input field of the apply to each to the one you mentioned and it now works well.
     

     body('Parse_JSON')?['employees']
  • Verified answer
    Expiscornovus Profile Picture
    32,155 Most Valuable Professional on at
    Re: Cannot Parse JSON - The result must be a valid array.

    Hi @therush321,

     

    The error suggests that the employee array is empty (because of the null value error message). Can you check if the parse json output contains any value in that field?

     

    Additionally I noticed that the expression/value you are using in the apply to each input is using the body property twice. (One via the body function and the second as a property after the ?). Looking at your schema you only have one body property.

     

    Can you try the expression below in the input field of your apply to each:

     

     

    body('Parse_JSON')?['employees']

     

     

     

    If that doesn't work you could also try and use the outputs function instead:

     

     

    outputs('Parse_JSON')?['body']?['employees']

     

     

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1