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": []
}
]
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/
Michael E. Gernaey
798
Super User 2025 Season 2
Tomac
469
Moderator
Power Apps 1919
333