cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cazzym
Helper I
Helper I

Custom Connectors - Ommitting Properties with a Null Value from the Request

I have a custom connector. For simplicity's sake, let's say a request is of the format

{

   "foo" : 5,

   "optional_bar" : 3

}

optional_bar is optional, so this will work

{

  "foo": 5

}

But this will not work

{

"foo": 5,

"optional_bar" : null

}

This is a feature of the API I am communicating with, not Power Automate. So here is my question.

 

Sometimes optional_bar will be null, sometimes it will contain a value. How can I stop the custom connector / Power Automate including any property whose value is null?

 

Yes I could use a conditional to check if its null, and then call an action with or without that field filled in. However my example is simplified - in real life there may be many many properties with nulls and including all permutations would be difficult.

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User III
Super User III

Hi @Cazzym 

 

I will suggest a dirty solution which might work.

 

image.png

 

Above expression is as follows:

 

replace(string(outputs('Compose_2')),outputs('Compose'),'')

 

My Test Result

 

image.png

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

6 REPLIES 6
abm
Super User III
Super User III

Hi @Cazzym 

 

This post might be helpful.

 

How to build a custom connector for Flow and PowerApps to connect to a web service - Alex Tofan's bl...

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

Hi @abm. I have built a custom connector. It works fine. The problem is that in the Flow action if I leave the optional parameter blank it works fine (the property is omited from the request), but if I have a dynamic value in that field that either returns  NULL, the connector fails (the property is not ommitted from the request). How can I get the custom connector to omit a property if it resolves as blank?

abm
Super User III
Super User III

Hi @Cazzym 

 

Thanks for your reply. Can't you validate the dynamic value before it hits the connector action step? 

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

@abmso I could have a Condition before, and if its a null it runs one action that doesn't include the optional parameter, and if the parameter is not null it runs a different action that does include the optional parameter. Only... I have about 5 different parameters that might be null or not null, which would require me to have a nesting series of if statements with 2^5 = 32 different permutations.

abm
Super User III
Super User III

Hi @Cazzym 

 

I will suggest a dirty solution which might work.

 

image.png

 

Above expression is as follows:

 

replace(string(outputs('Compose_2')),outputs('Compose'),'')

 

My Test Result

 

image.png

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

That is indeed a clever and dirty solution.

 

It doesn't work in my exact context because the foo and optional_bar have to be filled in as separate fields on the custom connector, so I can't just pass it the entire object with the optional_bar ommitted.

 

Buuut, I have taken inspiration from this solution to rework the custom connector so it just accepts an object with all the fields in it, in which case your solution works. Thanks!

 

I do view this as an ongoing problem in Power Automate. Its not the first time I've had this problem, and it's happened for me on actions which aren't custom connectors and I don't have the luxury of the method above. So if anyone has a solution to that, you're welcome to post even though @abm has solved my specific problem.

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (109,737)