Quick Fix: Microsoft Flow Error - Invalid type. Expected String but got Null.
Hi, today I came across JSON parser error in Microsoft Flow. I used auto-generated schema and everything had been working just fine until a connector I used had started to return null values for strings.
The fix is quite easy. You just need to manually modify a type of property in the schema. By default you get type String but it is not nullable type.
Fortunatelly JSON Parser in Microsoft Flow can handle multiple types in the schema:
{
"type": "array",
"items": {
"type": "object",
"properties": {
"Description": {
"type": [
"string",
"null"
]
}
}
}
}
So you just need to change
"type": "string"
to
"type": ["string", "null"]
Comments
Matt
what if i would like to stringify the json for that node and use/store it as a string in my database?
Sandro Alvares
Invalid type. Expected Number, Null but got Object. … how to solve?
Rostyslav
{ “type”: “object”, “properties”: { “Fields”: { “type”: “array”, “items”: { “type”: “object”, “properties”: { “FieldLabel”: { “type”: [ “string”, “integer” ] }, “Item”: { “type”: “string” }, “ItemElementName”: { “type”: “string” } } } }, “Links”: { “type”: “array”, “items”: { “type”: “object”, “properties”: { “rel”: { “type”: “string” }, “href”: { “type”: “string” } }, “required”: [ “rel”, “href” ] } }, “Id”: { “type”: “integer” }, “Title”: { “type”: “string” } } }
Doesn’t work form me,
Error Action ‘Parse_JSON_from_File’ failed
Any other ideas?
Rostyslav
Okay, so I did make it work, but if you use more than one type, the ITEM doesn’t appear in dynamic content.
Robson Parisoto
Thank you Tomas!
Nic Daniau
Thank you for providing the source of inspiration for something which has been bugging me for a while about parsing arrays. I’ve created a post on Stack Overflow with a link back to this one.
Visvire
god bless!
Paul Bartram
I had a different issue
Make sure your array has more than 1 object in it, else it fails with the same error because an array is only an array if it has more than 1 object.
This had me stumpped for a couple of hours
Cage
Does this work in Dynamic schema? as soon as I change the type from only “object” to “type”: [ “object”, “null” ], I get the error: The response from API with status code ‘200’ does not contain a valid OpenAPI schema object.
Kunal
Thank you Tomas!
Mete
Thank you so much ! it’s worked for me
Brian
I just changed: “type”: “string” to “type”: []
and it worked.
Omar
Thanks. When I send data from the PowerApps comes with different types. This solution was effective
Gilbert Quevauvilliers
This is awesome, and helped me resolve my error. Thanks!
Tom
Did the trick for me! Thanks a lot!
Ben Tatham
Thank you this worked for me where I was parsing users and one user had no department value which was causing the flow to fail. Updating the schema in this way solved the issue.
JJ Hepp
Thanks, this helped me!
AB
This was very helpful!
To submit comments, go to GitHub Discussions.