web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Custom Connectors - Om...
Power Automate
Answered

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

(0) ShareShare
ReportReport
Posted on by 42

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.

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    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 blog

     

    Thanks

  • Cazzym Profile Picture
    42 on at

    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 abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @Cazzym 

     

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

     

    Thanks

  • Cazzym Profile Picture
    42 on at

    @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.

  • Verified answer
    abm abm Profile Picture
    32,865 Most Valuable Professional on at

    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

     

  • Cazzym Profile Picture
    42 on at

    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.

  • Community Power Platform Member Profile Picture
    on at

    Hi there,

     

    I am having precisely the same problem. Updating an object using rest api I can update 10 attributes but if some of them are blank I don't want them to be replaced but just ignored. Can you explain how you change the custom connector with an object instead of parameters ?

     

    thanks a bunch 🙂

  • Cazzym Profile Picture
    42 on at

    Go edit the custom connector. Open up the Swagger editor, and look for the section with your request. You'll find the object and then under the object will be a list of properties. Clear out these properties, so it's just the object left. 

     

    The downside is you'll now need to construct an object, rather than having all the benefits of the parameters as neat little fields in your action. 

  • Community Power Platform Member Profile Picture
    on at

    Hi Cazzym,

     

    I think I understand the theory of it. Now I need to find some docs on how to construct said object in a flow. If you have any link or example that would be great but just this last message is really helpful.

     

    Thank you so much.

     

    Pierre

  • filipkarolowicz Profile Picture
    4 on at

    Hi @Cazzym! I know it's been a while since you posted this but could you share the Swagger definition which allowed you to pass the object with query parameters? I have exactly the same scenario as you had and keep getting errors thrown by the editor.

    Thanks a lot in advance!

    Karol 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard