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 / Downloading images fro...
Power Automate
Suggested Answer

Downloading images from hosted content - accessing images in body of teams message?

(0) ShareShare
ReportReport
Posted on by 11
When a user using Teams on an iPad adds images from the iPad photo library to a message, it adds them to the body of the message not as an attachment.

I have built a flow that can get the attachments of a Teams channel message and then do xyz with them, but cannot work out how to get images that are in the body of messages.

I have been experimenting with using the ‘Send a Microsoft Graph HTTP request’ action as I believe the images are somewhere in the hosted content?
 
However, this is going way beyond my current expertise!

I can’t find anyone else who has shared a working solution! – Can anyone help?
Categories:
I have the same question (0)
  • Mark Nanneman Profile Picture
    991 Super User 2025 Season 2 on at
    Interesting... what is the format of the image content in the message?  Can you post a screenshot?
     
  • robb1 Profile Picture
    11 on at


    "body": {
                "contentType": "html",
                "content": "<p>Test message content text.</p>\n<p>&nbsp;</p>\n<p><img src=\"https://graph.microsoft.com/v1.0/teams/c9d0e644-4171-4128-9edc-aff1c8b5d959/channels/19:0fa018bfdd6743fdbdb4cb3db9db2a53@thread.tacv2/messages/1731601758999/hostedContents/aWQ9eF8wLXN1ay1kNC01YzM5NGIxM2FlMWM2OTAyM2U3MTVlZjcyZWYzNDMyMyx0eXBlPTEsdXJsPWh0dHBzOi8vdWstYXBpLmFzbS5za3lwZS5jb20vdjEvb2JqZWN0cy8wLXN1ay1kNC01YzM5NGIxM2FlMWM2OTAyM2U3MTVlZjcyZWYzNDMyMy92aWV3cy9pbWdv/$value\" width=\"265\" height=\"157\" alt=\"image\" itemid=\"0-suk-d4-5c394b13ae1c69023e715ef72ef34323\"></p>",
                "plainTextContent": "Test message content text.\n&nbsp;\n"

  • Mark Nanneman Profile Picture
    991 Super User 2025 Season 2 on at
    Using "Send a Microsoft Graph HTTP" actions to get the content id and then the image file content seems like it should work, given some of the endpoints that are published, but I also could not get it to work at all either testing just now.  In fact I couldn't get any "Send a Microsoft Graph HTTP" to work, and when I tried using the demo ones on Microsoft's page they wouldn't work either.  Would love to hear if someone else knows more about it.

    That said, after a few tests I was eventually able to download the hosted content from a Teams message by parsing out the url from the <img> element's "src=" property and sending this to a HTTP GET action. 

    You can parse out the whole thing using some nested split() and first()/last() functions, or you could feed the message html to a GPT action and give it a prompt to extract the img url.

    The link to the image appears to follow this format.

    https://graph.microsoft.com/v1.0/chats/{chatId}/messages/{messageId}/hostedContents/{hostedContentId}=/$value

    You just get that and give it to a generic HTTP GET action (along with proper authentication).


    The only catch here is the HTTP GET action needs proper authorization.  There's probably a few ways to do it, I just used an App User I have for making other API calls in my system.  I had to go into Entra and grant it some Graph API Permissions to read chats, etc.

    Here's a camera snap I sent from my tablet to a teams chat.

    Here's the image after the flow saves it to sharepoint


     
  • robb1 Profile Picture
    11 on at
    Thanks very much Mark, I will give that a go and let you know the results!
  • Suggested answer
    CU01081649-1 Profile Picture
    2 on at
    The output body of a trigger such as "When a new Teams message Arrives" or "get Message Details" will have the text and image details in text. 

    This will not register as an attachment due to the either the device or method that the images were added to the original message. So, what you will see when you look at the message body that is returned with the appropriate card is a Graph endpoint address. Well, not really, it is the "first endpoint" 

    You would need to isolate the text that contains the http address that you need for a Graph HTTP request. This is a teams card. So, using methods to break down the text with compose to get to the http address. 

    You have to use the graph http request.  This is crucial, because if you do not use this card, most other http requests will not work. Or, you would need to set up tokens to establish your authorization for the data. This is handled neatly with this card. If you are working in an enterprise account - tokens would be an "ask" that would derail you. 

    The body output of the graph http request that you will get back will have another http address for the content. If you tried to paste this into a browser - you would get nothing. This is because the address you receive back is coded in this environment. The output you get is not decoded for the convenience that you would need to use in this form. It is coded in base64. 

    So, you would need to devise a strategy to isolate this address again to its basic form. Using split in a compose by quotation mark or </P> could get you there in steps or you build an expression to break this out. Once you have this - you would need to do another compose and decodeBase64. you can make an expression in one compose to do it all. Even the decode. But, take it in steps if you are not familiar. This helps you understand how to build expressions. And, further, check each part of your expression for faulty logic in the outputs to build the final combined compose. 
     
    THE DECODE:
    The output of that would be a recognizable address within your environment. But, this is just for content, and then you would need to do another graph HTTP request with this address. You would add/$value to the end of the address. This body that is returned would be a binary response of the file's contents that you could then use a create card to make a file. 

    I worked through this, and this is the hardest type of attachment to retrieve from a teams channel message. There is an "attachment" field in outputs but the fields that indicate that there is an attachment will be null, or "false". This is the sign where you would need this approach. You know there is an image, but it clearly indicates in outputs that there is no attachment. 

    If you are still interested in examples - respond and I will go through some demonstration if the appetite is still there. 

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 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard