cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Extract image from body of teams message (and convert to base64)

Hi,

 

I'm trying to get an image from the body of a teams message.

 

I know the image is stored in a location similar to this one:

 

https://graph.microsoft.com/beta/teams/eeca1618-16f7-40de-a402-bb1cfce7e9c4/channels/19:31bf2ce9492f...

 

From this URL I want to get the image data and convert it to base64 (if needed) in order to then write it to a CDS record.

 

Any help appreciated, thanks.

9 REPLIES 9
Super User II
Super User II

Re: Extract image from body of teams message (and convert to base64)

Hi @mrpowergage 

 

Find this similar issue that had a solution in it 

https://powerusers.microsoft.com/t5/General-Power-Automate/How-flow-get-image-from-ms-teams-to-send-...

 

Hope this help.

 

-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

 

Highlighted
Helper II
Helper II

Re: Extract image from body of teams message (and convert to base64)

Thanks but I don’t think this is the same issue.

The url is graph not sharepoint, and the image is in the body of the message, not an attachment.
Highlighted
Helper II
Helper II

Re: Extract image from body of teams message (and convert to base64)

Any one any ideas on this ? The issue is that the image is not an attachment, it is in the body of the message. See the JSON, the image source is in body.content attachments is empty. When I try and use the URL from the source I get an authentication error.

 

{
    "id": "1584227000439",
    "replyToId": null,
    "etag": "1584227185891",
    "messageType": "message",
    "createdDateTime": "2020-03-14T23:03:20.439Z",
    "lastModifiedDateTime": "2020-03-14T23:06:25.891Z",
    "deletedDateTime": null,
    "subject": null,
    "summary": null,
    "importance": "normal",
    "locale": "en-us",
    "webUrl": "https://teams.microsoft.com/l/message/19%3A31bf2ce9492f45d982681d3f1159657f%40thread.skype/1584227000439?groupId=eeca1618-16f7-40de-a401-bb1cfce7e9c4&tenantId=d838ff12-f626-4a30-b05e-aa4364197307&createdTime=1584227000439&parentMessageId=1584227000439",
    "policyViolation": null,
    "from": {
      "application": null,
      "device": null,
      "conversation": null,
      "user": {
        "id": "7a61d448-27a6-4196-8f7e-80e0aecb1471",
        "displayName": "XXXX",
        "userIdentityType": "aadUser"
      }
    },
    "body": {
      "contentType": "html",
      "content": "<div><div>\n<div>Test stuff<br>\n\n<img src=\"https://graph.microsoft.com/beta/teams/eeca1618-16f7-40de-a401-bb1cfce7e9c4/channels/19:31bf2ce9492f45d982681d3f1159657f@thread.skype/messages/1584227000439/hostedContents/aWQ9LHR5cGU9MSx1cmw9aHR0cHM6Ly91ay1hcGkuYXNtLnNreXBlLmNvbS92MS9vYmplY3RzLzAtc3VrLWQxLWZmMTE1YzZiYmQ1Zjk4MWY3YmM2YmJhMjkyMDBiZjYzL3ZpZXdzL2ltZ28=/$value\" style=\"width:800px; height:600px\"><br>\n\nReport 2 &amp; 3</div>\n</div>\n</div>"
    },
    "attachments": [],
    "mentions": [],
    "reactions": []
  },

 thanks

Highlighted
Super User III
Super User III

Re: Extract image from body of teams message (and convert to base64)

hi @mrpowergage  this is the full json? Because as you see the link with src image has a variable called Value.

 

https://graph.microsoft.com/beta/teams/eeca1618-16f7-40de-a401-bb1cfce7e9c4/channels/19:31bf2ce9492f.../$value\

 

So if we don't know what is in value is going to be imposible to get the image.

 

You could use parse json to get the "content": that is in json like this.

getformsImage.gif



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Helper II
Helper II

Re: Extract image from body of teams message (and convert to base64)

Thanks @ChristianAbata 

 


@ChristianAbata wrote:

hi @mrpowergage  this is the full json? Because as you see the link with src image has a variable called Value.

Yes that's the full json. As you can see the src it is a link to  https://graph.micro.... when I visit that link I get

 

{
  "error": {
    "code": "InvalidAuthenticationToken",
    "message": "Access token is empty.",
    "innerError": {
      "request-id": "2fd192af-c1c6-484a-9f8d-801ce208ed91",
      "date": "2020-03-15T13:25:06"
    }
  }
}

 I'm guessing I need to find a way to authenticate in order to get that data.

 

Any ideas??

Highlighted
Super User III
Super User III

Re: Extract image from body of teams message (and convert to base64)

ok @mrpowergage  please follow this post to do that https://sjoukjezaal.com/azure-b2b-sharepoint-online-solution-using-powerapps-flow-and-the-graph-api/

 



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Helper II
Helper II

Re: Extract image from body of teams message (and convert to base64)

Many thanks @ChristianAbata 

 

This looks beyond my expertise at this point. I may come back to it, but for now I'm going to find a different way to get the images into the system (probably Kaizala).

 

Thanks for all help.

Highlighted
Super User III
Super User III

Re: Extract image from body of teams message (and convert to base64)

@mrpowergage  sure Kaizala is more easy.



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Regular Visitor

Re: Extract image from body of teams message (and convert to base64)

Hi mrpowergage

 

Did you ever get this sorted out? I have the same question.

 

Regards,

Helpful resources

Announcements
secondImage

August 2020 CYST Winners!

Check out the winners of the recent 'Can You Solve These?' community challenge!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (4,807)