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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Image in word document
Power Automate
Unanswered

Image in word document

(1) ShareShare
ReportReport
Posted on by 58
Dear sir,
 
I need to put some image in a word document...
 
In my flow I have a "Compose" action with this expression
 
concat('data:image/', last(split(outputs('Ottieni_metadati_file_CLP1')?['body/Name'], '.')), ';base64,', base64(body('Ottieni_contenuto_file_CLP1')))
 
than I set a string variable with this value and after is inserted into the "populate word document" action.
 
But I have this error message:
 
Action 'Populate_a_Microsoft_Word_1_Template' failed: The image is not of type PNG or JPG. Please provide an image of type PNG or JPG
 
but my file is a jpg file (I have another compose where I see it).
 
Can some body help me ?
Thanks in advance
 
 
Categories:
I have the same question (0)
  • Jon Unzueta Profile Picture
    1,827 Super User 2025 Season 2 on at
     
    Thanks for the detailed explanation! The issue you're encountering is likely due to how the MIME type is being determined in your concat expression. Even though your file is a .jpg, the expression:
     

    last(split(outputs('Ottieni_metadati_file_CLP1')?['body/Name'], '.'))

    only extracts the file extension, which might not always match the actual MIME type required by the "Populate a Microsoft Word Template" action.

    Solution

    Instead of relying on the file extension, explicitly set the MIME type to ensure it's either image/jpeg or image/png.

    Try modifying your Compose expression like this:

     

    concat('data:image/jpeg;base64,', base64(body('Ottieni_contenuto_file_CLP1')))

    Or, if you're sure the file is a PNG:

    concat('data:image/png;base64,', base64(body('Ottieni_contenuto_file_CLP1')))

    Why this works:

    • The Word template action expects a valid data URI with a correct MIME type.
    • Using image/jpeg or image/png explicitly avoids issues with incorrect or unsupported types like image/jpg (which is technically not a standard MIME type).
     
    🏷️ Tag me if you have any further questions or if the issue persists.
    ✅ Click "Accept as Solution" if my post helped resolve your issue—it helps others facing similar problems.
    ❤️ Give it a Like if you found the approach useful in any way.
  • Suggested answer
    stampcoin Profile Picture
    5,058 Super User 2025 Season 2 on at
    @gcalab Hi,
    I think it takes jpeg or png, not quite sure..
    please try this one instead.
    concat(
      'data:image/',
      if(
        equals(toLower(last(split(outputs('Ottieni_metadati_file_CLP1')?['body/Name'],'.'))),'png'),
        'png',
        'jpeg'
      ),
      ';base64,',
      base64(body('Ottieni_contenuto_file_CLP1'))
    )
    also make sure you read the limitation.
  • gcalab Profile Picture
    58 on at
    Dear Stamcoin and Jon,
    first of all thank you for your time, but unfortunately I keep getting the same error "The image is not of type PNG or JPG..." Is it possible for you that the action "populate a word document" doesn't work with base64 files?
    Alternatively, how I can put my image inside word with an object variables ?
    Thank a lot for your attention.
     
  • Verified answer
    stampcoin Profile Picture
    5,058 Super User 2025 Season 2 on at
    @gcalab Hi,
    I think you don't need the compose. 
    when you specify the value for the field  in the word template.
    just choose body('Ottieni_contenuto_file_CLP1')
    received :
     
     
     
  • gcalab Profile Picture
    58 on at
    Dear stampcoin,
    that's right... it's simpler than I thought.
    Thank's a lot for your time, thanks also to Jon.
    You have a coffee payd if you came in Naples (Italy).
    Thanks again.
    Gennaro
     
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard