Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Image in word document

(0) ShareShare
ReportReport
Posted on by 52
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
 
 
  • gcalab Profile Picture
    52 on at
    Image in word document
    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
     
     
  • Verified answer
    stampcoin Profile Picture
    2,133 on at
    Image in word document
    @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
    52 on at
    Image in word document
    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.
     
  • Suggested answer
    stampcoin Profile Picture
    2,133 on at
    Image in word document
    @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.
  • Jon Unzueta Profile Picture
    751 on at
    Image in word document
     
    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.

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >