tag:blogger.com,1999:blog-3970629459363259828.post3731357030184148484..comments2024-03-28T11:25:49.045+13:00Comments on Linn's Power Platform Notebook: Handle Base64 and Binary File Content Types in Power AutomateLinn Zaw Winhttp://www.blogger.com/profile/16015532694415495453noreply@blogger.comBlogger27125tag:blogger.com,1999:blog-3970629459363259828.post-3065567812521506472024-02-20T19:59:03.966+13:002024-02-20T19:59:03.966+13:00Thank you all for sharing your experience/observat...Thank you all for sharing your experience/observation with the other readers. 😊Linn Zaw Winhttps://www.blogger.com/profile/16015532694415495453noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-9171002419423946952024-02-20T09:41:48.827+13:002024-02-20T09:41:48.827+13:00I was also struggling with this until I used the t...I was also struggling with this until I used the the base64() function. Thanks Tom for the heads up.Tafadzwa Chiwayehttps://www.blogger.com/profile/12556756091105434848noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-33457232394101865192024-01-27T08:59:58.259+13:002024-01-27T08:59:58.259+13:00My experience with Encodian-to-Microsoft actions w...My experience with Encodian-to-Microsoft actions were a bit different. I am using the Encodian "Convert HTML to PDF" action, and using the Outlook365 "Send an email (V2)" action to send the file contents generated by the "Convert HTML to PDF" action as an email attachment. In order for it to work, I had to configure the attachment file content like this:<br /><br />[<br /> {<br /> "Name": @{outputs('Convert_HTML_to_PDF')?['body/Filename']},<br /> "ContentBytes": {<br /> "$content-type": "application/pdf",<br /> "$content": "@{base64toString(base64(outputs('Convert_HTML_to_PDF')?['body']?['FileContent']))}"<br /> }<br /> }<br />]<br /><br />Yes, I had to explicitly use the base64() function to convert the file contents coming from Encodian to base64. Then, I convert to a string using base64toString() to decode back to a string. I'm not sure why it needs to be this way, but it does work.TomViolinhttps://www.blogger.com/profile/04455142354985668217noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-76871174679359979652024-01-18T21:43:16.761+13:002024-01-18T21:43:16.761+13:00Thank you, this was a superb. I started my Power a...Thank you, this was a superb. I started my Power automate journey at this week, and now I could get documents from external system and insert them to Notes table with correct format. <br />One good checking point for content formats is Content-Type header on API response. If header is "application/octet stream" then it's binary, else base64. Yes, there could be a some other variations, but mainly so.DerekHotgunshttps://www.blogger.com/profile/08001432114443655024noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-52029680848390558042023-06-13T07:44:50.040+12:002023-06-13T07:44:50.040+12:00Sorry, I don't know about that either. I just ...Sorry, I don't know about that either. I just checked the MS Learn page about it and it doesn't specify anything about it either.<br /><br />https://learn.microsoft.com/azure/logic-apps/workflow-definition-language-functions-reference?WT.mc_id=DX-MVP-5003873#base64tobinaryLinn Zaw Winhttps://www.blogger.com/profile/16015532694415495453noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-40181133134178955932023-06-13T01:52:35.565+12:002023-06-13T01:52:35.565+12:00I am attempting to access this data via PowerShell...I am attempting to access this data via PowerShell. It would seem doing the Base64 to Binary conversion may need an encoding type. Do you know what encoding type the Base64toBinary() function is using?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-783844820570883532023-05-31T21:15:21.782+12:002023-05-31T21:15:21.782+12:00Yes, that's what I was trying to explain the f...Yes, that's what I was trying to explain the first place about "shown as a JSON object with $content-type" which is the JSON representation of Binary Output.<br />At least glad to know that your mystery is solved.Linn Zaw Winhttps://www.blogger.com/profile/16015532694415495453noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-45856509588038386202023-05-31T19:04:58.863+12:002023-05-31T19:04:58.863+12:00Thank you! Linn. I realized that we cannot get the...Thank you! Linn. I realized that we cannot get the Binary Content even if we use the Base64toBinary Function after the Get File Content or in the File Creation step. If I'm not wrong the conversation function gives the JSON representation of Binary Output. <br /><br />https://app.screencast.com/rR4YKox2BhM2D<br />Ganapathyhttps://www.blogger.com/profile/02966500815844278895noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-86627638230326298932023-05-31T00:33:22.475+12:002023-05-31T00:33:22.475+12:00Yes, that depends on the format of the source data...Yes, that depends on the format of the source data. If the source data is Base64, you need to use Base64toBinary function.<br /><br />What is the source data of the content? If it is from the "Get file content" of SharePoint connector, you can just use without converting to binary.<br /><br />My test flow in designer mode - https://www.screencast.com/t/ZaBnZsMBJ4<br />Flow Run Result - https://www.screencast.com/t/aAtOcltFK5<br />Preview of uploaded file to SharePoint - https://www.screencast.com/t/kGjwD5qp62SU<br /><br />Another flow Create File using the content from Get file content without conversion - https://www.screencast.com/t/Do6CjHWKqsLinn Zaw Winhttps://www.blogger.com/profile/16015532694415495453noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-79070963179432612012023-05-30T23:22:14.704+12:002023-05-30T23:22:14.704+12:00Yes Linn, I opened the Notepad and checked. This t...Yes Linn, I opened the Notepad and checked. This time the Output file "BinaryText.txt" contain a String value instead of Binary. So I need to use the Base64toBinary function in the Create File Action in order to get the Binary content in the file?<br /><br />https://app.screencast.com/JRjNqd3acOMj1 - Flow<br />https://app.screencast.com/NItQmGajO14ur - Output File ContentGanapathyhttps://www.blogger.com/profile/02966500815844278895noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-3536477691920466522023-05-30T18:46:04.398+12:002023-05-30T18:46:04.398+12:00Have you tried opening it in Notepad and see the p...Have you tried opening it in Notepad and see the proper text? If that's the case we can say that your file was property created in SharePoint with correct content.<br /><br />In your next flow to Get File Content, the output of the action maybe in Base64 and that's depending on the content type of the action. No matter how you create the file, that content type will be in the same format. If you need the binary content there, you'll have to convert the Base64 to binary in that flow.Linn Zaw Winhttps://www.blogger.com/profile/16015532694415495453noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-76595284509272340572023-05-30T16:12:55.529+12:002023-05-30T16:12:55.529+12:00Yes Linn, I can see the BinaryText.txt file create...Yes Linn, I can see the BinaryText.txt file created in my SharePoint but when I open the file, I still see the same Base64 Content not the Binary Content.Ganapathyhttps://www.blogger.com/profile/02966500815844278895noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-39383755184959143312023-05-30T15:46:45.253+12:002023-05-30T15:46:45.253+12:00@Ganapathy
The output of the "base64ToBinary(...@Ganapathy<br />The output of the "base64ToBinary(outputs('Get_file_content')?['body'])" is indeed binary data. It is just that the flow run history would show it as a JSON wih $content.<br /><br />I don't see any issue with your flow and after your "Create file" action created a file in SharePoint, are you able to download and open the "BinaryTest.txt file and see the content?Linn Zaw Winhttps://www.blogger.com/profile/16015532694415495453noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-2520138592158313112023-05-30T15:15:09.015+12:002023-05-30T15:15:09.015+12:00Hello Linn, Thanks for your response. I have tried...Hello Linn, Thanks for your response. I have tried in the same way but I still get the file content as Base64 value. <br /><br />In my 1st Compose, I get the "File Content" ( and in the 2nd Compose, I used the base64toBinary Function "base64ToBinary(outputs('Get_file_content')?['body'])" , as you said it still shows as Base64 value. <br /><br />My file Content is like this "IDQgMCBSL0dyb3VwPDwvVHlwZS9Hcm91cC9TL1RyYW5zcGFyZW5jeS9DUy9EZXZpY" and I'm trying to convert the file content as Binary like "01100101 01101110 01100100 01101111 01100010 01101010"<br /><br />Please correct me if my flow or the function used wrongly. <br /><br />https://app.screencast.com/collections/g000300tJtSY9mm2flXH3uq9zMfTYGanapathyhttps://www.blogger.com/profile/02966500815844278895noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-57618444533493665932023-05-29T21:35:55.871+12:002023-05-29T21:35:55.871+12:00@Ganapathy
When you use base64toBinary function to...@Ganapathy<br />When you use base64toBinary function to get the Binary value of the File content, it still shows the Base64 values in the flow designer as part of the output value but it is a bit different.<br /><br />https://www.screencast.com/t/EbIqRrYXU<br />If you look at the screenshot above, the first Compose action contains the Base64 data. The second Compose action is the binary data after converting with the base64toBinary function (which has shown as a JSON object with $content-type even though the value of the $content is still Base64).<br />However, you can use that value to create a SharePoint "Create File" action File Content, it will just work.Linn Zaw Winhttps://www.blogger.com/profile/16015532694415495453noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-92007895355651438422023-05-29T18:27:35.018+12:002023-05-29T18:27:35.018+12:00Hi Linn, I'm trying to convert the Base64 file...Hi Linn, I'm trying to convert the Base64 file as a Binary file in SharePoint using Power Automate. But when I use the Base64toBinary function to get the Binary value of the File content, it gives the same Base64 values from my Base64 file. Is there any other way I can convert the Base64 file content value to Binary ?Ganapathyhttps://www.blogger.com/profile/02966500815844278895noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-31291023931127394262023-05-12T08:17:07.907+12:002023-05-12T08:17:07.907+12:00Populate a Microsoft Word template action was list...Populate a Microsoft Word template action was listed under the Base64 section of my blog. It only accepts the base64 format, so you will need to apply base64(…) function returned by your Power Automate download File Action.<br /><br />You can try to add it in the Compose step<br />https://msolenacrm.files.wordpress.com/2020/09/image-18.png<br /><br />and see if the output of the compose step looks something like this.<br />https://msolenacrm.files.wordpress.com/2020/05/image-14.png<br /><br />Check out Olena's blog post for more details.<br />https://msolenacrm.blog/2020/05/12/populating-word-template-with-the-cds-image-field-content-via-flow-power-automate/Linn Zaw Winhttps://www.blogger.com/profile/16015532694415495453noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-6923474800102519022023-05-04T04:59:52.404+12:002023-05-04T04:59:52.404+12:00error detail : The image is not of type PNG or JPG...error detail : The image is not of type PNG or JPG. Please provide an image of type PNG or JPG.\r\nclientRequestId: 79bb026c-0e30-4d1c-8262-0d8920b1bb2fAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-78860034736781350292023-05-04T04:57:57.975+12:002023-05-04T04:57:57.975+12:00I a still having a bad request error on word docum...I a still having a bad request error on word document generationAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-64626167940560032722023-05-04T04:56:46.339+12:002023-05-04T04:56:46.339+12:00I'm trying different ways to make it works wit...I'm trying different ways to make it works without success.<br /><br />From what I understand from your post is that the word template should accept the format ("binary") returned by Power automate download File Action. Here my variable (this example is using a png file but I tried Jpeg as well).<br /><br /> {<br /> "inputs": {<br /> "name": "signature",<br /> "value": "{\n\"$content-type\":\"image/png\",\n\"$content\":\"@{body('Télécharger_un_fichier_ou_une_image')['$content']}\"\n}"<br /> },<br /> "metadata": {<br /> "operationMetadataId": "a95e30cc-1dd3-40a0-a04e-aeeb1abacac5"<br /> }<br />}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-90184764063299053742022-07-14T06:56:08.862+12:002022-07-14T06:56:08.862+12:00Is there a way to custom populate the Library Name...Is there a way to custom populate the Library Name? We have the same flow across multiple sites, and I was trying to build a variable to populate the Library Name, but it looks like the flow is expecting a GUID for Library Name. <br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-80832685694745079652021-07-13T22:58:11.544+12:002021-07-13T22:58:11.544+12:00You will have to create multiple Attachment (Activ...You will have to create multiple Attachment (ActivityMimeAttachment) rows with those file content as mentioned in the step 5 of this blog post.<br /><br />https://linnzawwin.blogspot.com/2020/05/send-email-from-dynamics-365cds-with.html#CreateAttachmentLinn Zaw Winhttps://www.blogger.com/profile/16015532694415495453noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-17573877911213939972021-06-18T12:18:57.266+12:002021-06-18T12:18:57.266+12:00If you want to get a multiple files contents, (.xl...If you want to get a multiple files contents, (.xls,.csv,.txt,.jpg) and send them in one email, which expression should be use to to fit all of them<br />Anonymoushttps://www.blogger.com/profile/11149343180980873543noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-65182740230676008002021-04-20T08:21:35.367+12:002021-04-20T08:21:35.367+12:00I am not sure how it was working previously but as...I am not sure how it was working previously but as mentioned in my example below, you will need to provide Base64 value to create a Note attachment. If you are using the expression base64ToBinary(), the input value becomes binary and thus, it is failing with that error.<br /><br />https://linnzawwin.blogspot.com/2021/02/handle-base64-and-binary-file-content.html#binary-to-base64Linn Zaw Winhttps://www.blogger.com/profile/16015532694415495453noreply@blogger.comtag:blogger.com,1999:blog-3970629459363259828.post-19389277701575805252021-04-19T22:31:44.835+12:002021-04-19T22:31:44.835+12:00Hi,
We have been using this expression base64ToBin...Hi,<br />We have been using this expression base64ToBinary() to create a note related case, when portal comment is added from dynamics portal.<br />From yesterday the flow has started failing on the conversion step, due the mentioned flow error.<br /><br />Message for Error:<br />{<br /> "error": {<br /> "code": "0x80040278",<br /> "message": "Invalid character in field 'documentbody': '.', hexadecimal value 0x00, is an invalid character.",<br /> "@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionSourceKey": "Plugin/Microsoft.Crm.ObjectModel.AnnotationService",<br /> "@Microsoft.PowerApps.CDS.ErrorDetails.ApiStepKey": "753b8615-ecd8-db11-b397-0019b9204da9",<br /> "@Microsoft.PowerApps.CDS.ErrorDetails.ApiDepthKey": "1",<br /> "@Microsoft.PowerApps.CDS.ErrorDetails.ApiActivityIdKey": "5eacdd4f-8dbc-4add-9ec0-47ea1ef0da17",<br /> "@Microsoft.PowerApps.CDS.ErrorDetails.ApiPluginSolutionNameKey": "System",<br /> "@Microsoft.PowerApps.CDS.ErrorDetails.ApiStepSolutionNameKey": "System",<br /> "@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionCategory": "ClientError",<br /> "@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionMesageName": "InvalidCharactersInField",<br /> "@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionHttpStatusCode": "400",<br /> "@Microsoft.PowerApps.CDS.HelpLink": "http://go.microsoft.com/fwlink/?LinkID=398563&error=Microsoft.Crm.CrmException%3a80040278&client=platform",<br /> "@Microsoft.PowerApps.CDS.InnerError.Message": "Invalid character in field 'documentbody': '.', hexadecimal value 0x00, is an invalid character."<br /> }<br />}<br /><br /><br />Any idea why this is happening? Nothing has been changed from our end.Anonymousnoreply@blogger.com