Skip to main content

Notifications

Community site session details

Community site session details

Session Id : DQKxT1LT+znCF2luFnUwXu
Power Automate - Building Flows
Unanswered

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

Like (0) ShareShare
ReportReport
Posted on 14 Nov 2024 15:58:47 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?
  • robb1 Profile Picture
    11 on 15 Nov 2024 at 09:57:47
    Downloading images from hosted content - accessing images in body of teams message?
    Thanks very much Mark, I will give that a go and let you know the results!
  • Mark Nanneman Profile Picture
    989 Super User 2025 Season 1 on 14 Nov 2024 at 19:26:50
    Downloading images from hosted content - accessing images in body of teams message?
    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 14 Nov 2024 at 16:34:12
    Downloading images from hosted content - accessing images in body of teams message?


    "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
    989 Super User 2025 Season 1 on 14 Nov 2024 at 16:02:53
    Downloading images from hosted content - accessing images in body of teams message?
    Interesting... what is the format of the image content in the message?  Can you post a screenshot?
     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard
Loading started