Forum Discussion

Pierre_Z92's avatar
Pierre_Z92
Copper Contributor
Nov 29, 2022

Download chatMessage attachments

Hello,

 

I am using the Graph API to fetch chatMessages of a particular user (using delegated permissions).

 

I am unable to download attachments of those chatMessages ; a GET query to the contentUrl (https://learn.microsoft.com/en-us/graph/api/resources/chatmessageattachment?view=graph-rest-1.0), returns "401 UNAUTHORIZED" error.

The contentUrl looks like : https://{devTenant}-my.sharepoint.com/personal/{userEmail}_onmicrosoft_com/Documents/Microsoft Teams Chat Files/{fileName}

The bearer token that I provide comes from this endpoint : https://login.microsoftonline.com/common/oauth2/v2.0/token (and works for any other call to the Graph API).

 

Do you have any idea of how to download attachments ?

 

Thank you in advance,

Pierre

17 Replies

    • Meghana-MSFT's avatar
      Meghana-MSFT
      Former Employee
      we are also seeing the same behavior. We will check internally and get back to you.
      • Meghana-MSFT's avatar
        Meghana-MSFT
        Former Employee

        Pierre_Z92 - Engineering team has said that - 

         

        You can use this API - https://learn.microsoft.com/en-us/graph/api/shares-get?view=graph-rest-1.0&tabs=http Plug in the sharepoint link from chatMessage attachment and it will get you the download links you need. Additional reference https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=http

Resources