cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SueA
Resolver II
Resolver II

How to deal with an empty XML File in Power Automate?

 I have an XML File generated by a PowerBI report and sent to us as an email attachment.

I have a FLOW1 that takes the Email attachment and places in a SP Library.

My Flow2 takes the File Content from SP Library and creates records in the SP List.

The FLOW2 works fine as long as there are records in the XML File.

However, we got an XML file with no records. My FLOW failed at Parse JASON step.

How do I circumvent this issue as every now and then there may be a file with no records - Just a header?!

 

I tried condition step with 

length(outputs('Get_file_content')?['body/value'])  greater than 0
and
it gave me the following error:
"InvalidTemplate. Unable to process template language expressions for action 'Condition' at line '1' and column '39899': 'The template language function 'length' expects its parameter to be an array or a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#length for usage details.'."
 
Please help.
Thanks,
SueA
 
1 ACCEPTED SOLUTION

Accepted Solutions
v-chenzhi
Community Support
Community Support

Hi @SueA ,

 

When the xml file is empty, do you want to continue running the flow2 even if Parse JSON fails?

I found an alternative method for your reference, please try the following workaround.

vchenzhi_0-1637292768035.png

Choose Configure run after, Select all these scope statuses you need.

vchenzhi_1-1637292768038.png

Here is the expression:

result('Scope')[0]['status']

 

 

Best Regards,

Zhi Chen

View solution in original post

1 REPLY 1
v-chenzhi
Community Support
Community Support

Hi @SueA ,

 

When the xml file is empty, do you want to continue running the flow2 even if Parse JSON fails?

I found an alternative method for your reference, please try the following workaround.

vchenzhi_0-1637292768035.png

Choose Configure run after, Select all these scope statuses you need.

vchenzhi_1-1637292768038.png

Here is the expression:

result('Scope')[0]['status']

 

 

Best Regards,

Zhi Chen

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (6,187)