web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Power Apps Camera Save Image to Sharepoint Folder

(5) ShareShare
ReportReport
Posted on by 10

I have built a Canvas Power App to take a photo and send it to a Sharepoint Folder. My camera control is "Camera1" and I have a text input field for the filename "SKUInput" I have a Submit button with this code in OnSelect: If( !IsBlank(SKUInput.Text), NewStockPhotos.Run( SKUInput.Text & ".jpg", // File name JSON(Image1.Image, JSONFormat.IncludeBinaryData) // File content ), Notify("Please enter a SKU.", NotificationType.Error) ) I am using a Power Automate template called NewStockPhotos. It is a Microsoft template found here: https://make.powerautomate.com/environments/Default-774d3f34-6850-4d5b-856b-92537239edf7/galleries/public/templates/fe971b57c1994482b565ccfce936900d/upload-a-photo-to-sharepoint-from-power-apps. I have added my Sharepoint Site and the Folder for Storing the images \New Stock Photos.

I cannot get it to save the image to my Sharepoint folder. It fails in the Compose section of the Power Flow with this message:

InvalidTemplate Unable to process template language expressions in action 'Convert_to_binary_image' inputs at line '0' and column '0': 'The template language function 'dataUriToBinary' expects its parameter to be formatted as a valid data URI. The provided value '' was not formatted correctly. Please see https://aka.ms/logicexpressions#dataUriToBinary for usage details.'.

Any ideas? Regards from Richard

I have tried using CoPilot to help but it is taking me around in circles. Apart from adding my SharePoint site and folder name "New Stock Photos" I have used the Power Automate template as it comes

I have the same question (0)
  • Verified answer
    Daivat Vartak (v-9davar) Profile Picture
    7,827 Super User 2025 Season 2 on at
    Power Apps Camera Save Image to Sharepoint Folder
    Hello indigouk,
     

    You've encountered a common issue with the dataUriToBinary function when working with images from Power Apps in Power Automate: the image data isn't being passed in the expected Data URI format.

    Here's a breakdown of the problem and how to fix it:

    Understanding the Problem:

    • JSON(Image1.Image, JSONFormat.IncludeBinaryData):

      • This part of your Power Apps code converts the image data into a JSON string that includes the binary data.
      • However, this JSON string is not directly compatible with the dataUriToBinary function in Power Automate. 

    • dataUriToBinary Expectation:

      • The dataUriToBinary function in Power Automate expects the image data to be in a Data URI format, which looks something like: data:image/jpeg;base64,....
      • The JSON string you're sending doesn't have this format. 


    •  

    Solution:

    You need to modify your Power Apps code to extract the base64 encoded image data from the JSON string and format it as a Data URI before sending it to Power Automate.

     

    Modified Power Apps Code:

    If(

        !IsBlank(SKUInput.Text),

        NewStockPhotos.Run(

            SKUInput.Text & ".jpg", // File name

            "data:image/jpeg;base64," & Mid( // Create Data URI

                JSON(Image1.Image, JSONFormat.IncludeBinaryData), // Get JSON

                Find(",", JSON(Image1.Image, JSONFormat.IncludeBinaryData)) + 1 // Find base64 data

            )

        ),

        Notify("Please enter a SKU.", NotificationType.Error)

    )

     

    Explanation of Changes:


    1. JSON(Image1.Image, JSONFormat.IncludeBinaryData):

      • This remains the same, getting the JSON representation of the image. 

    2. Find(",", ...):

      • This finds the position of the comma (,) in the JSON string, which separates the metadata from the base64 encoded image data. 

    3. Mid(..., Find(",", ...) + 1):

      • This extracts the base64 encoded image data from the JSON string, starting after the comma. 

    4. "data:image/jpeg;base64," & ...:

      • This prepends the Data URI header (data:image/jpeg;base64,) to the extracted base64 data, creating the correct format for dataUriToBinary.
      • If your images are not jpeg, then change the "jpeg" portion of the string to the correct file extension. 

      •  

    5.  

    Power Automate Flow:

    You should be able to use the Power Automate template as it is, as long as the data is sent in the correct format.

     

    Troubleshooting Tips:

    • Image Format: Ensure that your camera control is capturing images in a format that Power Automate can handle (e.g., JPEG, PNG).
    • Large Images: Very large images might cause issues. Try capturing smaller images to test.
    • Power Automate Run History: Check the run history of your Power Automate flow for detailed error messages.
    • Testing: Use the Power Apps monitor tool to check the value of the image data being sent to Power Automate.

    •  

    By making these changes, your Power Apps should send the image data to Power Automate in the correct Data URI format, and the dataUriToBinary function should work correctly.

     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak
  • Verified answer
    Ramesh Kumar Profile Picture
    7,503 Super User 2025 Season 2 on at
    Power Apps Camera Save Image to Sharepoint Folder

    Can you please check if you follow the below UAT test case to see 

    Test the flow independently with a hardcoded image to ensure the Power Automate flow works as expected

    Double-check the Power Automate template to ensure you're using the correct data passed from Power Apps. 

    Revisit Power Apps and ensure you're passing the image properly as binary data with JSON(Camera1.Photo, JSONFormat.IncludeBinaryData).

     

    Thanks, Ramesh

    If this was helpful, please check the "Does this answer your question?" box and mark it as verified.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
DAnny3211 Profile Picture

DAnny3211 251

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 137 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 90 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans