cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TakeshiOsanai
New Member

How to handle "null" value in JSON when developing the Custom Connector of the Power Platform and Automate?

I'm developing the Custom Connector and the Automate on the Power Platform.

Let's say that:

  • The Automate flow receive JSON via the custom connector

  • The JSON response data has over hundreds of properties

  • The JSON may have "null" value on some of properties, and they cannot be predictable what property have the null value

  • According to that reason, I have to handle the null value with the Custom Connector

To avoid error, what kind of method can I have with developing the connector?

 

FYI: I found the Microsoft's document, but the below way cannot be used because of the reason I wrote above.

https://support.microsoft.com/en-us/topic/getting-errors-with-null-fields-d0a36825-72eb-bd78-dcc0-26...

3 REPLIES 3
manuelstgomes
Super User II
Super User II

Hi @TakeshiOsanai 

 

There's another way to enable null values. In the JSON definition you should have something like this:

{
    "type": "object",
    "properties": {
        "days": {
            "type": "integer"
        }
    }
}

 

In the example above we're indicating that "days" is a integer and only an integer. If it's something else it will fail. Since null is not an integer you get an error every time there's a null value.

 

To fix it you need to define that the value can receive 2 types. The actual type (string, integer, etc) and null. So you can do something like this:

{
    "type": "object",
    "properties": {
        "days": {
            "type": [
                "integer",
                "null"
            ]
        }
    }
}

 

Do this for all the types that you know that a null value is possible. Don't forget, in the Flow, to deal with the null values so not to save invalid values.

 

Now the type can be 2 things and not only one.

 

Does this make sense?

 

Can you please check if and let me know if you have any questions?

 

Cheers
Manuel

-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

TakeshiOsanai
New Member

Hi @manuelstgomes.

Thank you for your quick response, and sorry for my late reply.

 

Let me ask you more in detail.

Is this solution the official way to solve the null problem and written in Microsoft's documentation?

Or is this an unofficial workaround?

 

The reasons of my asking are:

* I want to make the connector  certified by Microsoft and reveal it to the connector's page
https://flow.microsoft.com/en-US/connectors/
 

* I am wondering that Microsoft suddenly change the specification of the Automate and this workaround will be invalitated or not.

This may be the needless worry, but want to clear.

Thanks in advance!

manuelstgomes
Super User II
Super User II

HI @TakeshiOsanai 

 

Great question. This is how JSON schemas work so it's not a workaround.

https://json-schema.org/understanding-json-schema/reference/null.html

 

Good luck with the submission.

 

Cheers
Manuel

-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

 

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Users online (90,649)