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!
Great
LikeLiked by 1 person
Great work. Also notable for people just learning the action: the “required” schema at the of the definition.
LikeLike
You are welcome
LikeLike
Brilliant, you’re a lifesaver
LikeLike
Im glad I could help
LikeLike
Is this error simply because people aren’t uploading a file when given the option – do i have to correct the error?
LikeLike
We don’t always have the correct file covering all possible values and scenarios to generate the schema.
LikeLike
It seems that Power Automate is pretty far behind Integromat and Zapier when it comes to automating flows, unless one is trying to use Dynamics 365, in which case you don’t have a choice but to use Power Automate. This business with having to rewrite your JSON just to get nulls to work is ridiculous. Maybe I’m missing something?
LikeLike
I’d say you are right. It’s good to have a choice. We choose tools which solve our problems better. Within Office 365 space my choice would be to use tools from the same eco system. You’ve got some coding choices as well. It depends on what you are building.
LikeLike
Super. Thank you very much.
LikeLike