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 / Parse JSON, Invalid ty...
Power Automate
Answered

Parse JSON, Invalid type. Expected Object but got Array

(0) ShareShare
ReportReport
Posted on by 299

I've built a flow that connects to the O365 Management Service and retrieves the last 24 hours of audit logs in JSON. 

 

When I try to parse the JSON I get an error. Can anyone suggest why? 

This is the first part of the JSON. 

 

 

[
 {
 "AppAccessContext": {
 "CorrelationId": "aaaa-606d-7000-1193-a81da98aeed8",
 "UniqueTokenId": "aaaa-XZA8nAA"
 },
 "CreationTime": "2023-07-31T02:27:19",
 "Id": "aaaa-87c5-433f-ed5a-08db916daa64",
 "Operation": "FilePreviewed",
 "OrganizationId": "aaaa-8c30-4f06-bb03-a0fc334c4f9f",
 "RecordType": 6,
 "UserKey": "i:0h.f|membership|aaaa@live.com",
 "UserType": 0,
 "Version": 1,
 "Workload": "OneDrive",
 "ClientIP": "aaaa.105.139.166",
 "ObjectId": "https://aaaa-my.sharepoint.com/aaaa",
 "UserId": "aaaa.aaaa@aaaa-ltd.com",
 "AuthenticationType": "OAuth",
 "BrowserName": "",
 "BrowserVersion": "",
 "CorrelationId": "aaaa-606d-7000-1193-a81da98aeed8",
 "DoNotDistributeEvent": true,
 "EventSource": "SharePoint",
 "IsManagedDevice": true,
 "ItemType": "File",
 "ListId": "aaaa-55ff-4d42-9bcd-cc2c2c409f53",
 "ListItemUniqueId": "aaaa-02b6-4832-893d-a863f1e7b623",
 "Platform": "Service",
 "Site": "aaaa-e37a-4708-9325-e513144bd894",
 "UserAgent": "OneDriveMpc-Transform_Thumbnail/1.0",
 "WebId": "aaaa-ffe3-4b99-80e4-63b23b3b01a0",
 "DeviceDisplayName": "aaaa.79.237.33",
 "HighPriorityMediaProcessing": false,
 "ListBaseType": 1,
 "ListServerTemplate": 700,
 "SourceFileExtension": "html",
 "SiteUrl": "https://aaaa-my.sharepoint.com/aaaa",
 "SourceFileName": "Microsoft Bing Travel - Copenhagen.html",
 "SourceRelativeUrl": "Documents/Desktop"
 },

 

 



schema ;

 

 

{
 "type": "object",
 "properties": {
 "content": {
 "type": "array",
 "items": {
 "type": "object",
 "properties": {
 "AppAccessContext": {
 "type": "object",
 "properties": {
 "ClientAppId": {
 "type": "string"
 },
 "ClientAppName": {
 "type": "string"
 },
 "CorrelationId": {
 "type": "string"
 },
 "TokenIssuedAtTime": {
 "type": "string"
 }
 }
 },
 "CreationTime": {
 "type": "string"
 },
 "Id": {
 "type": "string"
 },
 "Operation": {
 "type": "string"
 },
 "OrganizationId": {
 "type": "string"
 },
 "RecordType": {
 "type": "integer"
 },
 "UserKey": {
 "type": "string"
 },
 "UserType": {
 "type": "integer"
 },
 "Version": {
 "type": "integer"
 },
 "Workload": {
 "type": "string"
 },
 "ClientIP": {
 "type": "string"
 },
 "ObjectId": {
 "type": "string"
 },
 "UserId": {
 "type": "string"
 },
 "ApplicationDisplayName": {
 "type": "string"
 },
 "ApplicationId": {
 "type": "string"
 },
 "AuthenticationType": {
 "type": "string"
 },
 "CorrelationId": {
 "type": "string"
 },
 "EventSource": {
 "type": "string"
 },
 "IsManagedDevice": {
 "type": "boolean"
 },
 "ItemType": {
 "type": "string"
 },
 "ListId": {
 "type": "string"
 },
 "ListItemUniqueId": {
 "type": "string"
 },
 "Site": {
 "type": "string"
 },
 "WebId": {
 "type": "string"
 },
 "DeviceDisplayName": {
 "type": "string"
 },
 "HighPriorityMediaProcessing": {
 "type": "boolean"
 },
 "ListBaseType": {
 "type": "integer"
 },
 "ListServerTemplate": {
 "type": "integer"
 },
 "SourceFileExtension": {
 "type": "string"
 },
 "SiteUrl": {
 "type": "string"
 },
 "SourceFileName": {
 "type": "string"
 },
 "SourceRelativeUrl": {
 "type": "string"
 }
 },
 "required": [
 "AppAccessContext",
 "CreationTime",
 "Id",
 "Operation",
 "OrganizationId",
 "RecordType",
 "UserKey",
 "UserType",
 "Version",
 "Workload",
 "ClientIP",
 "ObjectId",
 "UserId",
 "ApplicationDisplayName",
 "ApplicationId",
 "AuthenticationType",
 "CorrelationId",
 "EventSource",
 "IsManagedDevice",
 "ItemType",
 "ListId",
 "ListItemUniqueId",
 "Site",
 "WebId",
 "DeviceDisplayName",
 "HighPriorityMediaProcessing",
 "ListBaseType",
 "ListServerTemplate",
 "SourceFileExtension",
 "SiteUrl",
 "SourceFileName",
 "SourceRelativeUrl"
 ]
 }
 }
 }
}

 

 

 
and the error;

 

 

[
 {
 "message": "Invalid type. Expected Object but got Array.",
 "lineNumber": 0,
 "linePosition": 0,
 "path": "",
 "schemaId": "#",
 "errorType": "type",
 "childErrors": []
 }
]

 

 

 

 

nick9one1_0-1690817807012.png

 

Categories:
I have the same question (0)
  • Verified answer
    nick9one1 Profile Picture
    299 on at

    I solved this by using a 3rd party JSON to JSON Schema converter. It seems the built in 'generate from JSON' button doesnt work too well. 
    https://redocly.com/tools/json-to-json-schema/

    then I validated the json using this tool 

    https://www.jsonschemavalidator.net/ 

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard