A JSON schema that tolerates null
Quiz question
Parse JSON fails with "Expected String but got Null". What helps?
Solution
- A) Adding the field to the required list as wellWrong. required only checks whether the field is present. It does not fix the type error on null.
- B) Setting the type to a list of string and nullCorrect. With ["string", "null"] the schema accepts text and null, and validation passes.
- C) Generating the schema from a new sample responseWrong. A new sample again sets exactly one type per field. The next null fails validation again.
What it is about
Parse JSON checks every response against a schema. If you generate the schema from a sample response, the designer sets exactly one type per field, such as string. When a field later arrives as null, the action fails with "Invalid type. Expected String but got Null." The fix is a type list: "type": ["string", "null"] accepts text and null. If a field is sometimes missing entirely, you remove it from the required list. If both can happen, you do both. The exact cause of a failed validation is in the action's outputs in the errors array. The run itself only reports that schema validation failed.
The expression from the tip
"type": ["string", "null"]When to use it, when not
Use it
For responses from APIs and forms where fields may stay empty.
Better not
For fields that must never be empty. There the schema validation should fail and show the error.
Most common mistake
Reading only the run's error message. The exact cause is in the outputs of Parse JSON in the errors array.
License
Standard Runs without a premium connector, so the license from Microsoft 365 is enough. Source on Microsoft Learn: Power Automate licensing FAQ. For your whole flow: License check.
Prefer to learn with guidance? The Power Automate live course of the Power Platform Academy takes you from the basics to error handling and scopes in four weeks.
Share
Short link: powerautomate.ninja/en/104
Source: PowerPlatformTip #104, Microsoft Learn: Use data operations in Power Automate.