cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NorthernChuck
Helper III
Helper III

ValidationFailed Parse JSON

Hello,

  I received this error, "ValidationFailed. The schema validation failed.", for the Parse JSON data operation function. The app further noted, "This is a new issue. Try posting about it on our community page—somebody may have a fix. Post it now" 🙂

This error is coming after a select step at the Parse JSON function. (Plz ignore the Create CSV Table <- I was trying something which sorta worked but not really, not as twitchy-clean as I wanted 😛 )  My end goal here is to shove the values of 'Select_Data_Into_New_Array' TriggerIssue && TriggerWorkstation && TriggerThreshold into previously initialized variables (set to string).  Any ideas, help, memes or even sarcasm is greatly appreciated at this time. 

Screenshot Overview.png

 

I use a successful RUN and grabbed a sample from the RAW Output from the Select step.  

Raw Output of sample.png

 

I copy and pasted the above RAW output into the "Generate from Sample" window in the Parse JSON step. This is what it generated. 

code beautify.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

@Pstork1 IT WORKS!!!!
Thank you for your replies and helping with the "brian stew" !!!
I took the raw intput contents with the square brackets, added it to the autogenerator and bam! success! Now I am in an Apply To Each loop (power automates equivalent of ForEach I guess) and I can assign the value for my previously declared variables. Thank you! 🙂 

If anyone else gets that Validation error and reads this thread, for me in this instance it was clearly related to the SCHEMA. 
Cheers, 

it works.png

 

View solution in original post

9 REPLIES 9
NorthernChuck
Helper III
Helper III

Here's the error output.

 

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

I suspect that when you created the schema you used the entire body, but when parsing the output you are only using array inside the body.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 Thank you kindly for your reply. To answer with any accuracy I would need you to be more specific. This is 1 component of a larger flow of logic. If you look at the step "Select Data Into New Array" you can see I'm using content from a previous step labelled as "arrMessages". Using that content I remap to labels that I define. This is done in the Select step. (I have since deleted the CSV table step, it no longer served a purpose anyways) 
The RAW Output of that select step is pasted as a screenshot above. I selected the whole thing, copied it and pasted it into the Generate window as described. Can you point me to where I may have inserted the incorrect data? I feel like this should be very simple and I'm missing something obvious. So I'm a-okay triple checking everything to find the "Office Space decimal point" that's in the wrong spot 😄

 

$varTriggerIssue = $select_data_into_new_array[0].TriggerIssue <--- this is really what I want to do.. how do I do that in PowerAutomate? Maybe parse Json after the select is the wrong thing to do ? I tried set variable in various ways and kept failing.... (varTriggerIssue has been previously initialized as a string with no value)
 

When you run the Parse Json I suspect you are are parsing the JSON array called body in your ouput.  But if you copy all of that output and put it in to generate the schema it will generate a schema for an unnamed object that contains an array called body.  To generate your schema you only want the section from the opening '[' to the closing ']' not everything inside the {}.

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

I tried again with a custom schema and received the same error and similar error output. In my mind it is clearly the schema and it is a matter of tweaking it -OR I'm going about this incorrectly and there's 1001x easier method than this 🙂 (anyone have any online schema generators they recommend?)
#Error Below

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

#This is the schema that generated the above error

{
    "type""object",
    "properties": {
        "TriggerIssue": {
            "type""string"
            },
        "TriggerWorkstation": {
            "type""string"
            },
        "TriggerThreshold": {
            "type""string"
            }
    },
    "required": [
        "TriggerIssue",
        "TriggerWorkstation",
        "TriggerThreshold"
        ]
}
Tried with custom schema 7APR.png

 

I see what you are saying. I used the raw output, this:

{
    "body": [
        {
            "TriggerIssue""Empty TriggerIssue",
            "TriggerWorkstation""Empty Trigger Workstation",
            "TriggerThreshold""Empty Trigger Threshold"
        }
    ]
}
 
What you are suggesting is using this with the auto-generator:
{
"TriggerIssue": "Empty TriggerIssue",
"TriggerWorkstation": "Empty Trigger Workstation",
"TriggerThreshold": "Empty Trigger Threshold"
}

Trying now..... 

@Pstork1 no dice mate; close but no cigar 😄 You can see as it comes in as RAW input, there's square brackets around the array - so it's an object with an array (unless I'm reading it wrong) - would compose be better than Parse JSON ? 

Tried with suggestion 1.png

 

@Pstork1 IT WORKS!!!!
Thank you for your replies and helping with the "brian stew" !!!
I took the raw intput contents with the square brackets, added it to the autogenerator and bam! success! Now I am in an Apply To Each loop (power automates equivalent of ForEach I guess) and I can assign the value for my previously declared variables. Thank you! 🙂 

If anyone else gets that Validation error and reads this thread, for me in this instance it was clearly related to the SCHEMA. 
Cheers, 

it works.png

 

View solution in original post

Try this schema

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "TriggerIssue": {
        "type": "string"
      },
      "TriggerWorkstation": {
        "type": "string"
      },
      "TriggerThreshold": {
        "type": "string"
      }
    },
    "required": [
      "TriggerIssue",
      "TriggerWorkstation",
      "TriggerThreshold"
    ]
  }
}


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

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
Top Kudoed Authors
Users online (81,306)