web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Cannot Parse JSON - Th...
Power Automate
Unanswered

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

 

Categories:
I have the same question (0)
  • Verified answer
    Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    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']

     

     

     

  • therush321 Profile Picture
    on at

    @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']
  • jguthrie25414 Profile Picture
    2 on at

    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.

  • tandey Profile Picture
    6 on at

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

  • dsab81 Profile Picture
    Microsoft Employee on at

    This one below worked for me . Thanks @Expiscornovus 

     

    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard