Microsoft Tech Community Live:  Microsoft Teams Edition
November 09, 2021, 08:00 AM - 12:00 PM (PST)

Can't Get Files of channels from team using graph api

%3CLINGO-SUB%20id%3D%22lingo-sub-2367918%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20Get%20Files%20of%20channels%20from%20team%20using%20graph%20api%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2367918%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1033425%22%20target%3D%22_blank%22%3E%40hidayat3676%3C%2FA%3E%26nbsp%3B%20_%20You%20can%20send%20an%20attachment%20to%20teams%2C%20the%20file%20is%20saved%20in%20the%20share%20point%2C%20which%20you%20can%20view%20in%20the%20files%20folder%20of%20the%20team%2C%20You%20can%20get%20the%20file%20details%20and%20URL%20to%20the%20file%20in%20share-point%20using%20.%20But%20you%20cannot%20get%20the%20content%20of%20file%20using%20Graph%20API.%20Please%20check%20get%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fchannel-get-filesfolder%3Fview%3Dgraph-rest-1.0%26amp%3Btabs%3Dhttp%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Efilesfolder%3C%2FA%3E%20to%20get%20file%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2370826%22%20slang%3D%22en-US%22%3ERe%3A%20Can't%20Get%20Files%20of%20channels%20from%20team%20using%20graph%20api%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2370826%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F590590%22%20target%3D%22_blank%22%3E%40Nikitha-MSFT%3C%2FA%3E%20The%20link%20you%20mentioned%20just%20return%20the%20folder%20path%2C%20I'm%20interested%20to%20get%20files%20and%20it's%20content%20can%20you%20please%20refer%20me%20to%20the%20doc%20for%20it.%20As%20you%20mentioned%20it's%20not%20possible%20using%20graph%20then%20how%20can%20i%20access%20the%20file%20content%20as%20there%20any%20other%20api%20exists%20for%20it%20or%20it%20is%20not%20possible%20to%20access%20it%20using%20api%20at%20all%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2363882%22%20slang%3D%22en-US%22%3ECan't%20Get%20Files%20of%20channels%20from%20team%20using%20graph%20api%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2363882%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI've%20an%20Oauth%20App%20thorough%20which%20i%20can%20access%20teams%2C%20channels%20and%20channels%20messages%20including%20attachments%20but%20not%20getting%26nbsp%3B%20attachment%20content%26nbsp%3B%20%26nbsp%3Busing%20the%20same%20token.%3C%2FP%3E%3CP%3Efollowing%20as%20an%20example%20attachment%20url%20which%20i%20get%20from%26nbsp%3B%20teams%2F%7Bteamid%7D%2Fchannels%2F%7Bchannelid%7D%2Fmessages%3C%2FP%3E%3CP%3Ebut%3C%2FP%3E%3CP%3Ewhen%20i%20try%26nbsp%3B%3CSPAN%3Ehttps%3A%2F%2F%7Bmysubdomain%7D.sharepoint.com%2Fsites%2FPublic%2FShared%2520Documents%2FGeneral%2Ffile.txt%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eit%20return%20401%20Unauthorized%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Efollowing%20permissions%20are%20already%20given%20to%20the%20app.%3C%2FP%3E%3CP%3E%3CSPAN%3EFiles.Read.All%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EFiles.Read%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EChannelMessage.Read.All%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EPlease%20Guide%20on%20how%20to%20get%20the%20attachment%20using%20graph%20api.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2363882%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFiles%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Contributor

Hi,

I've an Oauth App created in AAD thorough which i can access teams, channels and channels messages including attachments but not getting  attachment content   using the same token.

following as an example attachment url which i get from  teams/{teamid}/channels/{channelid}/messages

but

when i try https://{mysubdomain}.sharepoint.com/sites/Public/Shared%20Documents/General/file.txt

 

it return 401 Unauthorized

 

following permissions are already given to the app.

Files.Read.All

Files.Read

ChannelMessage.Read.All

Please Guide on how to get the attachment using graph api.

5 Replies

@hidayat3676  _ You can send an attachment to teams, the file is saved in the share point, which you can view in the files folder of the team, You can get the file details and URL to the file in share-point using . But you cannot get the content of file using Graph API. Please check get filesfolder to get file

@Nikitha-MSFT The link you mentioned just return the folder path, I'm interested to get files and it's content can you please refer me to the doc for it. As you mentioned it's not possible using graph then how can i access the file content as there any other api exists for it or it is not possible to access it using api at all?
@Nikitha-MSFT This does not return files shared in team channels.
Can You please clarify if it is possible to access the file using api or not with relevant source if we can get it?

@hidayat3676 _ you will receive the file shared in the channel using Get files folder, which give the information about the file but it does not provide file content. If you want to get the file content you need to get the message when you shared the file in channel and usinng that message id get the file content using Get the raw contents of a file attachment on a message.