cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BrunoTww
Level: Powered On

Uploading Image to Dynamics 365 through PowerApps/Microsoft Flow

Hi all,

I've been trying to upload an image to CRM through Microsoft Flow.

I basically have an app that uses Camera component to take a picture, after the picture is taken, I want to create a record in Dynamics 365. I have a custom entity set up where its entityimage field is enabled. 

 

I am facing a bad request where the return message error is "Invalid Argument". Below you can see my request.

 

{
"cds_amount": 1,
"cds_customerlocation": "1",
"entityimage": "aVZCT1J3MEtHZ29BQUFBTlNVaEVVZ0FBQUFVQUFBQUZDQVlBQUFDTmJ5YmxBQUFBSEVsRVFWUUkxMlA0Ly84L3czOEdJQVhESUJLRTBESHhnbGpOQkFBTzlUWEwwWTRPSHdBQUFBQkpSVTVFcmtKZ2dnPT0="
}
 
And this is the response.
 
{
"status": 400,
"message": "Invalid argument.",
"source": "powerappsdemo2018.crm.dynamics.com",
"errors": [],
"debugInfo": "clientRequestId: 0f76d94e-ea8b-48f4-b462-a4b94206328c"
}
 
By the way, the base64 I'm showing is just an example, the base64 I take from the app is much bigger. All the base64 I've tested so far give me the same error and I have also checked multiple times if the base64 is valid.
 
I would appreciate any help.
 
Thank you
1 ACCEPTED SOLUTION

Accepted Solutions
BrunoTww
Level: Powered On

Re: Uploading Image to Dynamics 365 through PowerApps/Microsoft Flow

Hey, just had to come back to it after months and just realised how to do it.

 

The flow is really simple.

  1. I have a parameter called base64txt which will be supplied in my App.
  2. I then convert the base64txt to binary using the function base64ToBianry.
  3. Create desired record passing the output to Entity Image field.

 Untitled.png

 

Important noticing that to capture the image use the property .Photo of the camera, so if your camera component is called camera1 it would be camera1.Photo and the base64 returned starts with "data:image/png,base64,iVHDUAW...".

 

We need to remove this data:image/png,base64, piece so it would be only "iVHDUAW..." in my case. 

 

I chose to handle that on my App side but you can do whichever side you want.


Hope it helps

View solution in original post

4 REPLIES 4
AMoon
Level: Powered On

Re: Uploading Image to Dynamics 365 through PowerApps/Microsoft Flow

Hi! @BrunoTww Did you ever figure this out? I'm looking to do the same thing and encountering the same error. 

Highlighted
TopShelf-MSFT
Level 10

Re: Uploading Image to Dynamics 365 through PowerApps/Microsoft Flow

Bumping for visibility 

 

@TopShelf-MSFT 

BrunoTww
Level: Powered On

Re: Uploading Image to Dynamics 365 through PowerApps/Microsoft Flow

Hey, just had to come back to it after months and just realised how to do it.

 

The flow is really simple.

  1. I have a parameter called base64txt which will be supplied in my App.
  2. I then convert the base64txt to binary using the function base64ToBianry.
  3. Create desired record passing the output to Entity Image field.

 Untitled.png

 

Important noticing that to capture the image use the property .Photo of the camera, so if your camera component is called camera1 it would be camera1.Photo and the base64 returned starts with "data:image/png,base64,iVHDUAW...".

 

We need to remove this data:image/png,base64, piece so it would be only "iVHDUAW..." in my case. 

 

I chose to handle that on my App side but you can do whichever side you want.


Hope it helps

View solution in original post

BrunoTww
Level: Powered On

Re: Uploading Image to Dynamics 365 through PowerApps/Microsoft Flow

Just realized that you can use the function dataUriToBinary so you can just pass camera1.Photo value not having to replace anything. Much more clean way to do it.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,581)