Power automate is endless fun!
Today we are going to explore a very “simple” issue which are 2 issues actually:
- how to define “allow null” in a schema to avoid annoying errors
- how to get away with the 1. without the painful consequences
Let’s start from the beginning!
PARSE JSON is a very useful action and we use it a lot in Power Automate.In my case I parse the response from a third-party API to populate a CDS entity. We can use a Generate from sample to auto-generate a schema.

Which is totally awesome if you’ve got a sample which fully defines your schema. In my schema all values are optional. It doesn’t mean they will always be nulls but it’s bad enough to get a Power Automate error after the first run: “Invalid type. Expected String but got Null” So I understand that the generated schema has to be changed to allow nulls in the response.
We have to modify the schema manually.
There are 3 ways I know and I will list all 3 here below:
- Tell that Description can be null:
"LotReference": { "type": [ "string", "null" ] }
2. Tell we have no idea what it is y removing a type mentioning completely:
"LotReference": {}
3. Using anyof in the definition:
"LotReference": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }
I will tell you something: Power Automate hates the first option! Yes, it stops complaining and even parses your response and throughs no errors but it “hides” the Dynamics content values related to the response.
The second option is OK. I will show you the screenshot, however there is another issue with it. It has to be converted via expressions or variables somehow after. If you response is as long as mine this is the last thing you want, really.
There is an option 2 and 1 on the screenshot below.

With the Dynamic content hidden for ContactReference (option 1) and available for OwnerReference(option 2).


At last, the option 3 is there, in the Dynamic content, with the correct type!


If you want to learn more about PARSE JSON, read John’s blog post here: http://johnliu.net/blog/2018/6/a-thesis-on-the-parse-json-action-in-microsoft-flow
He uses a typeless option 2 in his example.
Happy parsing!
1 thought on “Power Automate: PARSE JSON action with value or null”