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

SDK Support for File type attributes?

There does not seem to be SDK support for the new File type attributes.

The documentation (here) talks about calling the web service directly when working with these, however the example methods require me to supply 7 parameters including an access token and don't seem to fit a real world example. I am not sure if that code is even achievable inside a plugin.

In addition, none of the tools that use CrmSvcUtil seem to generate a class for a File type attribute. Maybe there is better support in the upcoming release wave though if there is I couldn't find a reference.

I will continue to test eg late binding and accessing the web service inside a plugin or an external app eg a logic app, but would be grateful to hear if others have worked with File attributes in code and how you did it.

Super User
Super User

Hi @PJ99 


I haven't tried it out myself, but I remember seeing blogs where is explained how to work with the file attributes.

Something like this:

Maybe it helps.


Kind regards,


Thanks @DianaBirkelbach - great start thank you.

I was not aware of those SDK messages (InitializeFileBlocksDownloadRequest & InitializeFileBlocksUploadRequest etc) so a really useful post for me and I got the download to work using that. 

Unfortunately his blog has no upload equivalent and I am unable to get this working so obviously I have something wrong.  This is what I tried which executes without exception but no change occurs to the target record/attribute.  This File attribute is such a great CDS feature so I am surprised no-one seems to be using it in code.

private static void UploadFile(CrmServiceClient service, byte[] processedDoc)

InitializeFileBlocksUploadRequest req = new InitializeFileBlocksUploadRequest();
req.FileAttributeName = "rss_invoicefile";
req.FileName = "Invoice.docx";
req.Target = new EntityReference("rss_invoice", Guid.Parse("7d14c17f-be9e-ea11-a812-000d3ad20d1c"));

InitializeFileBlocksUploadResponse resp = (InitializeFileBlocksUploadResponse)service.Execute(req);

UploadBlockRequest uploadRequest = new UploadBlockRequest();
uploadRequest.BlockData = processedDoc;
uploadRequest.BlockId = GuidToBase64(Guid.NewGuid());
uploadRequest.FileContinuationToken = resp.FileContinuationToken;

UploadBlockResponse uploadResponse = (UploadBlockResponse)service.Execute(uploadRequest);
Console.WriteLine($"Reponse name: {uploadResponse.ResponseName}");



kind regards,

Helpful resources

PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!


Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Users online (43,144)