How to Create a Zip File Using Power Automate?

I worked on a requirement to create a zip file containing multiple documents stored in a SharePoint library using Power Automate. The task was to gather the files, compress them into a zip file, and store the zip file back into the SharePoint library for further use.

During this process, I found that Power Automate provides an effective solution, allowing the creation of zip files without requiring a premium subscription.

In this tutorial, I will tell you how to Create a Zip File Using Power Automate and that too without using any premium connector.

Create a Zip File Using Power Automate

Before creating the flow, we must create a SharePoint folder inside a document library and upload some documents you want to zip.

Power Automate Zip Files

Now follow the below steps:

1. In the Power Automate, click the Instant Cloud flow, enter the Flow name, and choose the trigger flow (i.e., manually trigger a flow).

How to create a Zip file in Power Automate for free

2. Add a compose action and provide a librarypath, which is the path to the root of the SharePoint site, and the ZipFolderPath is the relative path of the folder you want to Zip.

How to zip files in SharePoint using Power Automate
{
  "libraryPath": "/sites/PowerAutomateTutorial/HRDocuments",
  "zipFolderPath": "/Zip files"
}
How to Compress Files to a Zip Archive in Power Automate

3. Then add a Send an HTTP request to SharePoint action from sharePoint Connector with the below parameter:

  • Site Address: Select the SharePoint site where you want the list to be created
  • Method: Select “POST” as the method
  • URI: Provide the below URI:
_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1=%27@{encodeUriComponent(outputs('Compose')['libraryPath'])}%27&RootFolder=@{encodeUriComponent(concat(outputs('Compose')['libraryPath'], outputs('Compose')['zipFolderPath']))}
  • Body: Provide the below JSON format:
{"parameters": {"RenderOptions": 4103}}
How to Create a Zip Archive with Advanced Options in Power Automate

This action I use to retrieve data from a specific folder within a SharePoint library. It is particularly useful when working with files or folders within the library, such as reading the contents of a folder or processing files.

4. Next, add compose action using the below expression:

@{body('Send_an_HTTP_request_to_SharePoint')['ListSchema']['.driveAccessToken']}
Working with Zip Files in Power Automate

5. Now add select action and provide below parameters:

  • From: Provide below expression:
@{body('Send_an_HTTP_request_to_SharePoint')['ListData']['Row']}
  • Map:
nameitem()[‘FileLeafRef’]
sizeitem()[‘SMTotalSize’]
docIditem()[‘.spItemUrl’] & Output(‘Compose_1’)
isFolderif(equals(item()[‘FSObjType’],’1′), true, false)
Power Automate make a Zip archive from items selected

6. Again, add a compose action using the below expression:

{
  "items": @{body('Select')}
}
Power Automate Add Files to ZIP

7. Then add a Send an HTTP request to SharePoint action from sharePoint Connector with the below parameter:

  • Site Address: Select the SharePoint site where you want the list to be created
  • Method: Select “POST” as the method
  • URI: Provide the below URI:
/transform/zip?cs=@{body('Send_an_HTTP_request_to_SharePoint')['ListSchema']['.callerStack']}
  • Headers: Add a key-value pair:
Content-Type : application/x-www-form-urlencoded
  • Body: Provide the below expression:
zipFileName=test.zip&guid=@{guid()}&provider=spo&files=@{encodeUriComponent(outputs('Compose_2'))}&oAuthToken=
Free Create Zip File Using Power Automate

8. Last add create file action and provide below parmeters:

  • Site Address: Select the SharePoint site address from the dropdown menu where you store zip files.
  • Folder Path: Select the folder path.
  • File Name: Provide the file name using the .zip extension.
  • File Content: Provide the below expression:
@{base64ToBinary(body('Send_an_HTTP_request_to_SharePoint_1')['$content'])}
Create a Zip File Using Power Automate

Run the Flow to Create a Zip File

Now, it’s time to save the flow. Click on Test -> Select Manually -> click Test. After the flow runs successfully, go to the SharePoint list, and you will see that the zip file was created successfully.

How to Create a Zip File Using Power Automate

In this article, I explained how to create a zip file containing multiple documents stored in a SharePoint library using Power Automate without premium connector.

Related Power Automate articles:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…