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

Community site session details

Session Id : u2oTbrBarVlJhET9EsL4vN
Power Automate - Building Flows
Answered

Parse JSON, Invalid type. Expected Object but got Array

Like (0) ShareShare
ReportReport
Posted on 31 Jul 2023 15:37:02 by 287

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

 

I have the same question (0)
  • Verified answer
    nick9one1 Profile Picture
    287 on 31 Jul 2023 at 16:46:14
    Re: Parse JSON, Invalid type. Expected Object but got Array

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 798 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 469 Moderator

#3
Power Apps 1919 Profile Picture

Power Apps 1919 333

Last 30 days Overall leaderboard
Loading complete