cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jakuza90
Helper I
Helper I

Issues with Parse JSON, invalid type expected object but got array

I'm trying to figure out what I'm doing wrong. I have a Powershell script that spits out JSON which then I try to Parse in Power Automate but I get this error:

 

"Invalid type. Expected Object but got Array."

 

I noticed that I can fix this when I change the first "type" in my schema to "array", but then I'm not able to do much with my Flow in terms of converting things like Date & Time. Here is the sample I use to generate the schema:

 

{
        "PrimarySmtpAddress":  "Person@email.com",
        "ManagedByDetails":  [
                             ],
        "ResourceProvisioningOptions":  [
                                        ],
        "HiddenFromAddressListsEnabled":  true,
        "HiddenFromExchangeClientsEnabled":  false,
        "WhenCreated":  "\/Date(1472137045000)\/",
        "WhenChanged":  "\/Date(1594744941000)\/",
        "Notes":  "Some Team"
    }

Here is what is generated:

 

 

 

{
    "type": "object",
    "properties": {
        "PrimarySmtpAddress": {
            "type": "string"
        },
        "ManagedByDetails": {
            "type": "object"
        },
        "ResourceProvisioningOptions": {
            "type": "array"
        },
        "HiddenFromAddressListsEnabled": {
            "type": "boolean"
        },
        "HiddenFromExchangeClientsEnabled": {
            "type": "boolean"
        },
        "WhenCreated": {
            "type": "string"
        },
        "WhenChanged": {
            "type": "string"
        },
        "Notes": {
            "type": "string"
        }
    }
}

 

 

 

 
4 REPLIES 4
yashag2255
Dual Super User II
Dual Super User II

Hi @Jakuza90 

 

Can you share some sample data that you are getting from the script? basically use that data to generate the PARSE JSON schema. 

 

In the sample you have shared you are just providing the object to parse json but I think the script is returning an array of objects which is why this is not working as expected. If you can share more details, we might be able to better assist you with this. 

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

v-litu-msft
Community Support
Community Support

Hi @Jakuza90,

 

The data in the WhenCreated and WhenChanged are ticks? 

If it is and you have problem with the convert ticks into valid date time, you could refer to this post:

https://powerusers.microsoft.com/t5/Building-Flows/Date-comparison-and-ticks/m-p/324563

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ignore this post.

@yashag2255 

 

This is the Outputs when the Flow is ran:

 

{
"PrimarySmtpAddress": "Email@Email.com",
"ManagedByDetails": [],
"ResourceProvisioningOptions": [],
"HiddenFromAddressListsEnabled": true,
"HiddenFromExchangeClientsEnabled": false,
"WhenCreated": "/Date(1472337045110)/",
"WhenChanged": "/Date(159374494100)/",
"Notes": "Agent Team"

This is the Content:

{
"PrimarySmtpAddress": "Email@Email.com",
"ManagedByDetails": [
],
"ResourceProvisioningOptions": [
],
"HiddenFromAddressListsEnabled": true,
"HiddenFromExchangeClientsEnabled": false,
"WhenCreated": "\/Date(147213733000)\/",
"WhenChanged": "\/Date(1594733941000)\/",
"Notes": "Agent Team"
}

When I remove this portion which occurs at the beginning of the schema: 

 

{
"type": [
"object",
"properties": {

 

Everything works just fine, but the problem with that is when I try to do a data operation for example: Compose, the only Inputs I can choose is "Body" and not the individual properties

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Users online (29,265)