Power Automate Json Schema

748 Views Asked by At

I am using power automate to pull some Json data from the Egnyte API. Power Automate generates a schema from example queries. The problem is the query it generates will not work on all queries because it will set type to "string" and some null values will be in some queries. Do I need to change all type from "string" to ["string","null"]? It seems like this is something Power automate should do automatically for types.

This is part of the error Message.

"message": "Invalid type. Expected String but got Null.", 

Here is the schema.

{
"properties": {
    "itemsPerPage": {
        "type": "integer"
    },
    "resources": {
        "items": {
            "properties": {
                "active": {
                    "type": "boolean"
                },
                "authType": {
                    "type": "string"
                },
                "createdDate": {
                    "type": "string"
                },
                "deleteOnExpiry": {
                },
                "email": {
                    "type": "string"
                },
                "emailChangePending": {
                    "type": "boolean"
                },
                "expiryDate": {
                },
                "externalId": {
                    "type": "string"
                },
                "id": {
                    "type": "integer"
                },
                "idpUserId": {
                    "type": "string"
                },
                "isServiceAccount": {
                    "type": "boolean"
                },
                "lastActiveDate": {
                    "type": "string"
                },
                "lastModificationDate": {
                    "type": "string"
                },
                "locked": {
                    "type": "boolean"
                },
                "name": {
                    "properties": {
                        "familyName": {
                            "type": "string"
                        },
                        "formatted": {
                            "type": "string"
                        },
                        "givenName": {
                            "type": "string"
                        }
                    },
                    "type": "object"
                },
                "role": {
                    "type": "string"
                },
                "userName": {
                    "type": "string"
                },
                "userPrincipalName": {
                },
                "userType": {
                    "type": "string"
                }
            },
            "required": [
                "id",
                "userName",
                "externalId",
                "email",
                "name",
                "active",
                "locked",
                "emailChangePending",
                "authType",
                "userType",
                "role",
                "idpUserId",
                "userPrincipalName",
                "expiryDate",
                "deleteOnExpiry",
                "createdDate",
                "lastModificationDate",
                "lastActiveDate",
                "isServiceAccount"
            ],
            "type": "object"
        },
        "type": "array"
    },
    "startIndex": {
        "type": "integer"
    },
    "totalResults": {
        "type": "integer"
    }
},
"type": "object"

}

2

There are 2 best solutions below

0
Expiscornovus On

Soon the parse json action should be able to handle null values.

This feature is expected to hit General Availability this month: https://learn.microsoft.com/en-gb/power-platform-release-plan/2022wave2/power-automate/parse-json-action-now-handles-null-objects

0
Michael Hearn On

In my case changing all the instance from "type" : "string" to "type" : ["string", "null"] did solve the problem. It allowed for the Power Automate JSON processing to work with no null value errors.