cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
seryil
Frequent Visitor

Insert JPG file (Picture) from HTTP Request in Word document

Hi all,

I have an HTTP Request in my cloud flow where I get data (JSON format) from a third-party API. In my response, I have a field with a URL to a specific picture (JPG format). I have created a Picture Content Control inside the Word document, and I need to insert the picture into this control.

I don't want to save the picture in OneDrive or SharePoint. I want to insert it directly.

I hope someone can help 🙂

10 REPLIES 10
fchopo
Super User II
Super User II

Hello @seryil 

The image should be converted to base64 before passing its value to Word. So the steps would be:

wordTemplate.png

 

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
seryil
Frequent Visitor

Hi @fchopo,

Thank you for your reply. I tried it and it doesn't work. Will this method work for URL images? And how would you do it if it was through SharePoint (saving the image in SharePoint)?

Paulie78
Super User III
Super User III

If I understand your question properly, you don't receive the image in your API response, only a URL. You will need to use the HTTP action first, with the URL that you receive in your API response to download the content of the image into your flow. You can then use the content from the HTTP request in your word connector and follow the instructions provided by @fchopo . Does that help? (The HTTP action is premium, so you will need a premium license).

seryil
Frequent Visitor

Hi @Paulie78,

The HTTP request is not a problem. I've fixed that.


seryil
Frequent Visitor

@fchopo @Paulie78 

The picture is inside of a repeating section content control in the Word Document. Could that be why it doesn't work?

fchopo
Super User II
Super User II

Hi @seryil 

I don't really know the answer to your last question, but I would try the same flow and using another simple Word document, where time image control is not in a repeating section.

Please, let us know if that's the problem!

Regards,
Ferran

 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
seryil
Frequent Visitor

Hi @fchopo 

It seems that Word doesn't support images within a repeating section content control: Support Image Controls within the Repeating Sectio... - Power Platform Community (microsoft.com).


But I think I can make a work around by saving the image in SharePoint and then replace the text in the table with the image stored in SharePoint. But I can't save the image I get from my API (URL image) in SharePoint. Is it something you can help me with?

I get the following message:

seryil_0-1618408614711.png

Do I need to convert the URL to Base64?

 

fchopo
Super User II
Super User II

Hello @seryil 

You should use dataUriToBinary function. Have a look at this sample (although I know your image is coming from an API and not from Power Apps): Taking a picture with PowerApps and sending to SharePoint with just Flow — John Liu .NET

Hope it helps!

Ferran

 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
seryil
Frequent Visitor

Hi @fchopo ,

But shouldn't I convert the URL to dataUri first, before I can convert it to Binary?

This is what I get from my JSON (string type):

 
And I want to save this image to SharePoint 🙂




fchopo
Super User II
Super User II

Hi @seryil 

I've done this test on my side, and it's working:

http_image.png

 

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

Helpful resources

Announcements
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

MPA 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

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (36,022)