Skip to main content

Notifications

Power Automate - Using Connectors
Answered

Parse JSON Error

(0) ShareShare
ReportReport
Posted on by 65

Greetings. I'm getting the following error:

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

 

 

The Sample Schema is:

{
 "type": "object",
 "properties": {
 "body": {
 "type": "array",
 "items": {
 "type": "object",
 "properties": {
 "id": {
 "type": "integer"
 },
 "name": {
 "type": "string"
 },
 "type_id": {
 "type": "integer"
 },
 "external_id": {},
 "parent_id": {
 "type": "integer"
 },
 "parent_external_id": {}
 },
 "required": [
 "id",
 "name",
 "type_id",
 "external_id",
 "parent_id",
 "parent_external_id"
 ]
 }
 }
 }
}

 

 

And the actual JSON I'm trying to parse, returned from a 3rd Party API, is: 

{
 "body": [
 {
 "id": 123456,
 "name": "ItemName",
 "type_id": 654321,
 "external_id": null,
 "parent_id": 0,
 "parent_external_id": null
 }
 ]
}

 

 

There's got to be a way to fix this, but I can't seem to figure it out. Thanks in advance for any advice.

  • Verified answer
    garnern2 Profile Picture
    garnern2 65 on at
    Re: Parse JSON Error

    Hi, I solved it. I actually needed to remove rather than add.

     

    Thanks.

     

    {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "id": {
     "type": "integer"
     },
     "name": {
     "type": "string"
     },
     "type_id": {
     "type": "integer"
     },
     "external_id": {},
     "parent_id": {
     "type": "integer"
     },
     "parent_external_id": {}
     },
     "required": [
     "id",
     "name",
     "type_id",
     "external_id",
     "parent_id",
     "parent_external_id"
     ]
     }
    }
  • garnern2 Profile Picture
    garnern2 65 on at
    Re: Parse JSON Error

    Hi Mohamed.

     

    I did as you stated. However, the outputs are unexpected. I get: Body, body, Items, Items. When I try to select id or name, an Apply To Each is automatically created. I've tried various combinations of the output from the previous steps. I chose Body>Body once, but it just entered a never-ending loop creating numerous duplicates of records until it timed out.

  • mobashee Profile Picture
    mobashee on at
    Re: Parse JSON Error

    Dear Partner,

    Add below syntax  before "type""object" and add two }} at the end and validate

     

    {
        "type""array",
        "items": {

     

    Did I answer your question? Please consider to mark my post as a solution to help others.

     

    Regards,

    Mohamed Sanuj Basheer

     

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,304

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard

Featured topics