cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dtietzeendsight
Regular Visitor

Array being read as type "Null" despite being declared as "Array" in Schema.

I am getting the following error: "ExpressionEvaluationFailed. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('parse_result_of_HTTP_GET_request_to_api.backupradar.com_as_JSON')?['content']?['Results']' is of type 'Null'. The result must be a valid array."

 

Of course, this seems to indicate I'm trying to evaluate something that's not an array, but my schema is as follows: 

{
  "type""object",
  "properties": {
    "content": {
      "type""object",
      "properties": {
        "Total": {
          "type""integer"
        },
        "Page": {
          "type""integer"
        },
        "PageSize": {
          "type""integer"
        },
        "TotalPages": {
          "type""integer"
        },
        "Results": {
          "type""array",
          "items": {
            "type""object",
            "properties": {
              "ticketingCompany": {
                "type""string"
              },
              "status": {
                "type""object",
                "properties": {
                  "id": {
                    "type""integer"
                  },
                  "name": {
                    "type""string"
                  }
                }
              },
              "daysInStatus": {
                "type""number"
              },
              "isVerified": {
                "type""boolean"
              },
              "lastResult": {
                "type""string"
              },
              "lastSuccess": {
                "type""string"
              },
              "ticketCount": {
                "type""integer"
              },
              "failureThreshold": {
                "type""integer"
              },
              "treatWarningAsSuccess": {
                "type""boolean"
              },
              "note": {
                "type""string"
              },
              "dayStartHour": {
                "type""integer"
              },
              "tags": {
                "type""array"
              },
              "standalone": {
                "type""boolean"
              },
              "history": {
                "type""array"
              },
              "backupId": {
                "type""integer"
              },
              "companyName": {
                "type""string"
              },
              "deviceName": {
                "type""string"
              },
              "deviceType": {
                "type""string"
              },
              "jobName": {
                "type""string"
              },
              "methodName": {
                "type""string"
              },
              "backupType": {
                "type""object",
                "properties": {
                  "id": {
                    "type""integer"
                  },
                  "name": {
                    "type""string"
                  }
                }
              }
            },
            "required": [
              "ticketingCompany",
              "status",
              "daysInStatus",
              "isVerified",
              "ticketCount",
              "failureThreshold",
              "treatWarningAsSuccess",
              "dayStartHour",
              "tags",
              "standalone",
              "history",
              "backupId",
              "companyName",
              "deviceName",
              "deviceType",
              "jobName",
              "methodName",
              "backupType"
            ]
          }
        }
      }
    },
    "schema": {
      "type""object",
      "properties": {
        "type": {
          "type""string"
        },
        "items": {
          "type""object",
          "properties": {
            "type": {
              "type""string"
            },
            "properties": {
              "type""object",
              "properties": {
                "date": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                },
                "ticketingCompany": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                },
                "status": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    },
                    "properties": {
                      "type""object",
                      "properties": {
                        "id": {
                          "type""object",
                          "properties": {
                            "type": {
                              "type""string"
                            }
                          }
                        },
                        "name": {
                          "type""object",
                          "properties": {
                            "type": {
                              "type""string"
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "daysSinceLastGoodResult": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                },
                "daysInStatus": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                },
                "daysSinceLastResult": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                },
                "resultsCount": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                },
                "isVerified": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                },
                "results": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    },
                    "items": {
                      "type""object",
                      "properties": {
                        "type": {
                          "type""string"
                        },
                        "properties": {
                          "type""object",
                          "properties": {
                            "dateTime": {
                              "type""object",
                              "properties": {
                                "type": {
                                  "type""string"
                                }
                              }
                            },
                            "success": {
                              "type""object",
                              "properties": {
                                "type": {
                                  "type""string"
                                }
                              }
                            },
                            "warning": {
                              "type""object",
                              "properties": {
                                "type": {
                                  "type""string"
                                }
                              }
                            },
                            "failure": {
                              "type""object",
                              "properties": {
                                "type": {
                                  "type""string"
                                }
                              }
                            },
                            "manual": {
                              "type""object",
                              "properties": {
                                "type": {
                                  "type""string"
                                }
                              }
                            },
                            "resultId": {
                              "type""object",
                              "properties": {
                                "type": {
                                  "type""string"
                                }
                              }
                            }
                          }
                        },
                        "required": {
                          "type""array",
                          "items": {
                            "type""string"
                          }
                        }
                      }
                    }
                  }
                },
                "policyId": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                },
                "companyName": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                },
                "deviceName": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                },
                "deviceType": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                },
                "policyName": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                },
                "methodName": {
                  "type""object",
                  "properties": {
                    "type": {
                      "type""string"
                    }
                  }
                }
              }
            },
            "required": {
              "type""array",
              "items": {
                "type""string"
              }
            }
          }
        }
      }
    }
  }
}
 
As you can see there, Results is clearly labeled as an array.
1 REPLY 1
DamoBird365
Microsoft
Microsoft

Hi @dtietzeendsight 

 

The error implies that the value "Results" that you are trying to access is either Null or doesn't exist.  The ? in an expression will return null if the path cannot be found.  If you remove the ?, flow will fail with an error.  So, you've either got a typo, your path doesn't exist or within your apply to each, one of the Results doesn't exist and so you might need to cater for when that value isn't there.


Cheers
Damien

Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts. Thanks

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (1,214)