Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Store File Content in a variable to create a file in Sharepoint

I have a flow that iterates through attachments in a Sharepoint list item and stores the file content in an array variable called "attachmentsToMerge" . If the array has more than 1 item, it calls a service to merge them and then the service returns the result in a "PDF File Content" that I can use to create the file in Sharepoint.   If the array attachmentsToMerge only has 1 item, I use the following expression to get the first stored file content to create the file in Sharepoint:  first(variables('AttachmentsToMerge')). This work when I use a "Create file" action in each separate branch of the "yes/no" control.


Ideally, I'd like to store whatever is returned in each one of the branches (either "PDF File Content" or what I get from the 'first' expression) and use the variable as the File Content to add to the "create file in Sharepoint" action, to be used after the yes/no control.

Ideal placement of "Create file in Sharepoint" actionIdeal placement of "Create file in Sharepoint" action


The File Content in the "create file" action only seems to accept a string variable. I tried storing the result of either branch in a string variable  (see variable "mergedFileContent" in snapshot) and used it in a "create file" and it didn't really worked. I'm only using PDFs file content, and the stored file content seems to pass some metadata to the "create file" action, as I can see for instance the right number of pages, but the content is blank.


I read the post "Store File Content in a variable" but it seems to apply only to File Content in emails. A user had a similar issue a mine, but that other post was unanswered. I would appreciate help on how to resolve this. 


Helpful resources

Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,063)