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 / Checking for null valu...
Power Automate
Unanswered

Checking for null value in JSON

(0) ShareShare
ReportReport
Posted on by 111

Hi, I am getting an error in my flow because the user is not submitting images to the SP list and my flow is built around the user submitting images, and then eventually populating a Word document with said images..

 

So my flow is stopping at this stage below: 

 

Unable to process template language expressions in action 'Initialize_variable' inputs at line '0' and column '0': 'The template language function 'json' expects its parameter to be a string or an XML. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#json for usage details.'.

 

This is my overall flow. I was hoping to add a conditional check for null before it initializes variables. 

 

For example: 

empty(json(body('HTTP_Request_-_Photo_2')?['d']['Image2'])['fileName'])
 
But does not seem to work. Any ideas? 
 

Albertax_0-1694497605511.png

 

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,335 Super User 2025 Season 2 on at

    Hi,

     

    I do not see a condition check. I do see where it has an issue, but the way you worded was that the conditional check didn't work and you want that fixed.

     

    Can you please clarify.
    Cheers
    If you like my answer, please Mark it as Resolved, and give it a thumbs up, so it can help others
    Thank You
    Michael Gernaey MCT | MCSE | Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • Albertax Profile Picture
    111 on at

    The conditional check control I have taken out in this case (because it mentioned something about the variable having to be at the top).

     

    But the use case for me is I want the flow to run anyway (even if the user does not include an image). My issue is my flow is succeeding when a user has an image within the SP Item, but I am also wanting the flow to succeed when the user does not include an image within the SP item (For example starting on a desktop and moving to their phone or etc).

     

    And i thought i could achieve it within the variable: empty(json(body('HTTP_Request_-_Photo_2')?['d']['Image2'])['fileName'])

  • Verified answer
    SanmeshG Profile Picture
    1,947 Moderator on at

    Hi @Albertax ,

     

    You can add the expression with an If condition inside of a Compose action and see if it works. Pass the output of the compose action to the initialize variable action.

     

    Else directly write the expression with the if condition in the initialize variable action. Example ,

     

    If(equals(triggerBody()['text_1'],'a'),'a',null)

    Here instead of equals condition you can use the above empty condition.

     

    Hope this helps!

     

    If this solves your issue please give it a thumbs up and mark it as a solution.

     

    Thanks,

    Sanmesh

     

  • Michael E. Gernaey Profile Picture
    53,335 Super User 2025 Season 2 on at

    I guess it's simply a matter of what you do if there is versus if there isn't.

     

    If there isn't and you check as @SanmeshG  suggests you can, just make sure later on if you plan to use that variable, you also need to take into account it will be null or empty or whatever you decide to set the variable too.

     

    As for your question on empty(json(body('HTTP_Request_-_Photo_2')?['d']['Image2'])['fileName'],

    empty and Null are not the same thing and it depends on which segment of the json/body is null/empty/blank

     

    you could also leverage Coalesce(json(body('HTTP_Request_-_Photo_2')?['d']['Image2'])['fileName'], json(body('HTTP_Request_-_Photo_2')?['d']['Image2'])['fileName'], 'default value')

     

    or If(IsBlank(json(body('HTTP_Request_-_Photo_2')?['d']['Image2'])['fileName']) or equals(json(body('HTTP_Request_-_Photo_2')?['d']['Image2'])['fileName'], Null), 'default value', json(body('HTTP_Request_-_Photo_2')?['d']['Image2'])['fileName']);


    Cheers
    If you like my answer, please Mark it as Resolved, and give it a thumbs up, so it can help others
    Thank You
    Michael Gernaey MCT | MCSE | Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard