Hi, I created a file field at powerapps and can upload a file in the CRM formular. Now I need an upload by C# and I found the classes:
InitializeFileBlocksUploadRequest and CommitFileBlocksUploadRequest
Fine except of the "BlockList" at CommitFileBlocksUploadRequest: How to set it correctly within byte-Array or base64 String?
public long UploadFileAsByteArray(ref IOrganizationService service, ref ITracingService tracingService, ref byte[] bytes, string fileName, EntityReference entityReference, string fieldNameOfFile) { string[] blockList = new string[1]; blockList[0] = InfSystem.GetBase64OfByteArray(bytes); InitializeFileBlocksUploadRequest initRequest = new InitializeFileBlocksUploadRequest { Target = entityReference, FileAttributeName = fieldNameOfFile, FileName = fileName, }; InitializeAnnotationBlocksUploadResponse initResponse = (InitializeAnnotationBlocksUploadResponse)service.Execute(initRequest); CommitFileBlocksUploadRequest commitRequest = new CommitFileBlocksUploadRequest { BlockList = blockList, MimeType = InfSystem.GetMimetypeByFilename(fileName), FileContinuationToken = initResponse.FileContinuationToken }; CommitFileBlocksUploadResponse comitResponse = (CommitFileBlocksUploadResponse)service.Execute(commitRequest); long fileSizeInBytes = comitResponse.FileSizeInBytes; return fileSizeInBytes; }