← Al Davies, 250 High Street

Fix "Invalid type. Expected String but got Null" in Power Automate

Parse JSON failed because a field arrived as null and your schema says it is a string. In the schema, change "type": "string" to "type": ["string", "null"] for that field, or wrap the value in coalesce(value, '') in a step before Parse JSON.

The Parse JSON action checks your data against a schema, so one null in a string field fails the whole step. Pick one fix on purpose, because each has a cost. This guide shows how to find the field, change the schema, and use coalesce, the function that swaps a null for a value you choose.

What the error means

In the run output the message reads "Invalid type. Expected String but got Null." Microsoft's troubleshooting page lists that exact message and translates it: "A field you're referencing is empty (null) and the action expects text." Its fix: "Wrap the reference in coalesce(field, '') or add a condition to check for null first."

Parse JSON takes text in JSON form and turns its parts into tokens you can pick in later steps. Microsoft's Azure Logic Apps page on data operations describes the same Parse JSON action and says: "For this action, you can either provide a JSON schema or generate a JSON schema from your sample JSON content or payload."

The schema is a list of rules. One rule says what kind of value each field holds. A field marked as a string must hold text. Null is not text. It means "no value". So when a run sends null where the schema says string, Parse JSON stops with an error that reads like "Invalid type. Expected String but got Null".

Here is a small example. Say another system sends your flow this:
{"Customer": "North Dental", "Notes": "Call back Friday"}

You use "Use sample payload to generate schema" and paste that in. The schema now says Notes is a string. Next week a record arrives with no notes:
{"Customer": "South Dental", "Notes": null}

The flow was fine for days and now fails. Nothing in your flow changed. The data changed.

The generated-schema trap

Our advice, not a Microsoft rule: a schema generated from one sample only knows about that one sample. If your sample had text in every field, expect the schema to say every field is text, and expect the first record with a null to fail.

Step 1. Find the field that is null

  1. Open https://make.powerautomate.com and open your flow.
  2. Open the run history and select the failed run.
  3. Open the Parse JSON step and read the error. Then open the step before it and read its output.
  4. Look through the output for the word null. Each match is a field that could break a string rule.
  5. Write down every field that is null. The error may name only the first one. Fix them all in one pass, or the next run will fail on the second one.

Exact names and screens may differ in your tenant. The idea is the same: read the data that went in.

Step 2. Decide which fix fits

Ask one question for each null field: is it allowed to be empty in real life?

Our advice, not a Microsoft rule: allow null only for fields that may truly be empty. Leave the required ones strict. A strict schema is an early warning.

Fix A. Allow null in the schema

JSON Schema is the standard that Parse JSON schemas follow. Its documentation says: "When type is used as an array, it contains more than one string specifying the types mentioned above." It also says: "In this case, the instance data is valid if it matches any of the given types."

This edit follows from JSON Schema, and null is one of the basic types that page lists. Test it on one record first. So instead of one type, you list two. Open the Parse JSON step and select the Schema box. Find the field and change it.

Before:
"Customer": { "type": "string" },
"Notes": { "type": "string" }

After (only Notes changes):
"Customer": { "type": "string" },
"Notes": { "type": ["string", "null"] }

Save the flow and run the failed record again. If Notes is a string or null, the check now passes.

Do the same for each field that may be empty. For a number field, use ["integer", "null"] or ["number", "null"]. Keep the other fields as they are.

One check to make: after you save, open a later step and look for the Notes token in the list of dynamic content. Our advice, not a Microsoft rule: confirm the token is still there after you change a field to two types. If it has gone, use the other fix, or type the value as an expression such as body('Parse_JSON')?['Notes']. The name inside the brackets must match your step name, with underscores in place of spaces.

Fix B. Change the value before Parse JSON runs

Microsoft's Azure Logic Apps functions reference, which also covers Power Automate, describes coalesce this way: "Return the first non-null value from one or more parameters. Empty strings, empty arrays, and empty objects aren't null."

You give coalesce a list of values. It returns the first one that is not null. So you can swap a null for a plain empty text.

Examples from the same page: coalesce(null, 'hello', 'world') returns "hello", and coalesce(null, null, null) returns null.

For our case, you can build the field so it never leaves as null:
coalesce(triggerBody()?['Notes'], '')

The two single quotes with nothing between them are an empty text. If Notes is null, you get empty text. If Notes has text, you get the text. Our advice, not a Microsoft rule: triggerBody()?['Notes'] fits data that arrives in the trigger body. Check the real path in your run history.

Important order of steps. Coalesce works on the data, so it must run before Parse JSON, or the data is already in the step that failed. A way to do that:

  1. Before the Parse JSON step, add a Compose step (search for Compose at https://make.powerautomate.com in your flow).
  2. In the Compose box, build the object with an expression for each field that may be null. Use coalesce on those fields only.
  3. Point the Parse JSON Content box at the Compose output.
  4. Re-run the failed record.

Our advice, not a Microsoft rule: use Fix B when the next steps need a plain string, such as an email body, and you do not want to test for null each time.

Coalesce has one limit that Microsoft states. Empty strings are not null. So coalesce('', 'none') returns the empty text and not "none". If the sender sends empty text and you want a default, coalesce will not swap it. Test with empty() instead. For that, see "Power Automate condition to check if a field is empty".

Which fix to use

You can use both on the same flow. Different fields need different rules.

Step 3. Test with a record that has nulls and a record that does not

  1. Run the flow with a record where every field is filled in.
  2. Run it with a record where only the optional fields are null.
  3. Run it with a record where a required field is null. Confirm that it fails the way you meant.
  4. Open the run history and check the output of the step after Parse JSON. An empty value should look the way you planned.

A green run only proves the check passed. Read the output to confirm the data is right.

When the Parse JSON step comes from a list

If the data comes from a SharePoint action such as Get items, the rows can run past 100. The Get items action stops at 100 rows by default, so a test that passes on a short list can still miss rows. Set Top Count and turn on Pagination. See "Power Automate Get items stops at 100 rows: how to get them all".

What to avoid

Limits of a generated schema

Microsoft's Azure Logic Apps page says of Parse JSON: "you can either provide a JSON schema or generate a JSON schema from your sample JSON content or payload." That helps when the schema is wrong, but a single sample cannot show every future null. Exact names may differ on your screen.

When to get help

You can build all of this yourself in Microsoft 365. If you would rather have it built and tested for your team, I do that. A tracker like this is a fixed price: $5,000 for one, built in 2 weeks. See "What a SharePoint tracker costs to build". Bring one example of the problem to a free call.

Tell me what's still manual

I am Al Davies. I run 250 High Street LLC and build SharePoint trackers and Power Automate flows for operations teams. I work remotely. The first call is free, and I will not try to sell you anything.

See trackers I built: Tools I built

FAQ

What does "Invalid type. Expected String but got Null" mean in Power Automate?

Microsoft's troubleshooting page translates it: "A field you're referencing is empty (null) and the action expects text." In Parse JSON it means the schema says string and the data sent null.

How do I generate the Parse JSON schema from a sample payload?

In the Parse JSON action, under the Schema box, select "Use sample payload to generate schema" and paste a sample. Microsoft's Azure Logic Apps page describes this option. Paste a sample that has a null in each optional field.

Is ["string", "null"] the right way to allow null?

It follows from the JSON Schema rule that when type is an array, "the instance data is valid if it matches any of the given types." Test it: confirm in your own flow that later steps still see the field.

Can I use coalesce inside Parse JSON?

No. Coalesce changes a value. Parse JSON checks the data first. Use coalesce in a step before Parse JSON, such as Compose, and point Parse JSON at that output. Our advice, not a Microsoft rule.

Why does coalesce not replace my empty text?

Microsoft's Azure Logic Apps functions reference says "Empty strings, empty arrays, and empty objects aren't null." Coalesce only swaps real nulls. To catch empty text, test with empty().

Sources