How to Download Large Files from Dynamics 365 CRM Using BlocksDownloadRequest API

By | December 12, 2025

How to Download Large Files from Dynamics 365 CRM Using BlocksDownloadRequest API

Introduction

When working with large files in Microsoft Dataverse (Dynamics 365 CRM), standard download methods often fail due to payload size limits, network interruptions, or memory overload. To address these challenges, Dataverse provides a chunked, block-based download mechanism through APIs such as:

  • InitializeFileBlocksDownloadRequest
  • InitializeAttachmentBlocksDownloadRequest
  • InitializeAnnotationBlocksDownloadRequest

This method is the recommended and most reliable way to download large files in Dynamics 365.

Why Use Chunked Download Requests?

Common challenges with large file downloads:
• Timeouts or payload size limits
• Unstable or slow networks (especially in mobile/VPN environments)
• Memory overload when downloading full files at once

To overcome these, Dataverse supports block-based downloads. These requests initialize the operation and return a continuation token and file metadata, enabling files to be retrieved in chunks.

Benefits of this approach include:
• Reliable, resumable downloads
• Optimized memory and bandwidth usage
• Scalable for mobile apps, portals, and external systems

Available Chunked Download Requests

  • InitializeFileBlocksDownloadRequest – For files stored in File or Image columns.
    • InitializeAttachmentBlocksDownloadRequest – For email attachments in the ActivityMimeAttachment table.
    • InitializeAnnotationBlocksDownloadRequest – For note attachments stored in the Annotation table.

How to Use Chunked Download Requests

The download process consists of three main steps:
1. Initialize the download request
2. Retrieve file blocks using DownloadBlockRequest
3. Assemble or save the file locally

Example 1: Downloading File Column Data

C# Code Sample:

var initRequest = new InitializeFileBlocksDownloadRequest
{
Target = new EntityReference("incident", incidentId),
FileAttributeName = "reportfile"
};

var initResponse = (InitializeFileBlocksDownloadResponse)service.Execute(initRequest);
var token = initResponse.FileContinuationToken;
var fileName = initResponse.FileName;
var fileSize = initResponse.FileSizeInBytes;

long offset = 0;
long blockSize = 4 * 1024 * 1024;
var fileBytes = new List<byte>();

while (offset < fileSize)
{
var downloadRequest = new DownloadBlockRequest
{
FileContinuationToken = token,
Offset = offset,
BlockLength = blockSize
};

var downloadResponse = (DownloadBlockResponse)service.Execute(downloadRequest);
fileBytes.AddRange(downloadResponse.Data);
offset += downloadResponse.Data.Length;
}

File.WriteAllBytes($"C:\\DownloadedReports\\{fileName}", fileBytes.ToArray());

Example 2: Downloading Email Attachments

To download an email attachment:

var initRequest = new InitializeAttachmentBlocksDownloadRequest
{
Target = new EntityReference("activitymimeattachment", attachmentId)
};

var initResponse = (InitializeAttachmentBlocksDownloadResponse)service.Execute(initRequest);
var token = initResponse.FileContinuationToken;
var fileSize = initResponse.FileSizeInBytes;

long offset = 0;
long blockSize = 4 * 1024 * 1024;
var fileBytes = new List<byte>();

while (offset < fileSize)
{
var downloadRequest = new DownloadBlockRequest
{
FileContinuationToken = token,
Offset = offset,
BlockLength = blockSize
};

var downloadResponse = (DownloadBlockResponse)service.Execute(downloadRequest);
fileBytes.AddRange(downloadResponse.Data);
offset += downloadResponse.Data.Length;
}

Example 3: Downloading Note Attachments

To download a note file from annotation: var initRequest = new InitializeAnnotationBlocksDownloadRequest { Target = new EntityReference(“annotation”, noteId) }; var initResponse = (InitializeAnnotationBlocksDownloadResponse)service.Execute(initRequest); var token = initResponse.FileContinuationToken; var fileSize = initResponse.FileSizeInBytes; long offset = 0; long blockSize = 4 * 1024 * 1024; var fileBytes = new List<byte>(); while (offset < fileSize) { var downloadRequest = new DownloadBlockRequest { FileContinuationToken = token, Offset = offset, BlockLength = blockSize }; var downloadResponse = (DownloadBlockResponse)service.Execute(downloadRequest); fileBytes.AddRange(downloadResponse.Data); offset += downloadResponse.Data.Length; }

Real-World Example: Case Attachments in Customer Support

Scenario:
Customer support agents frequently upload large evidence files into a Dataverse file column, such as high-resolution screenshots, diagnostic logs, product failure images, or customer-submitted recordings. These files often range from 10 MB to over 100 MB, especially when dealing with technical issues or multimedia evidence.

Challenge:
Using standard download methods often leads to:
• Browser timeouts due to file size
• Failed downloads for VPN/home-office users
• Performance issues when loading large files into memory
• Problems for Power Pages or portal users with unstable network conditions

Solution:
By using InitializeFileBlocksDownloadRequest, the system downloads large attachments in safe, resumable chunks (typically 4 MB each). If the network drops or a chunk fails, only that block is retried not the entire file.

Result:
• Escalation teams can download case evidence without interruption
• Remote and field technicians experience reliable downloads even on hotspot connections
• Large multimedia files no longer freeze or crash the application
• Faster resolution times and improved SLA performance

Conclusion

These chunked download requests offer a scalable, performant, and resilient way to retrieve large files from Dynamics 365 Dataverse. Whether working with file columns, email attachments, or notes, using block-based download logic ensures optimal handling of high-volume content in business-critical applications.

FAQ

1. Can I download files larger than 100MB using this method?

Yes. Block-based download supports very large files.

2. What is the recommended block size?

4 MB per Microsoft guidance.

3. Does chunked download work for Power Apps and external apps?

Yes, as long as the app uses the Dataverse Web API or SDK.

4. Can I resume a failed download?

Yes, you can retry the failed chunk because progress is tracked by offset.

Category: Dynamics 365 Technical Tags:

About Sam Kumar

Sam Kumar is the Vice President of Marketing at Inogic, a Microsoft Gold ISV Partner renowned for its innovative apps for Dynamics 365 CRM and Power Apps. With a rich history in Dynamics 365 and Power Platform development, Sam leads a team of certified CRM developers dedicated to pioneering cutting-edge technologies with Copilot and Azure AI the latest additions. Passionate about transforming the CRM industry, Sam’s insights and leadership drive Inogic’s mission to change the “Dynamics” of CRM.