I'm trying to dev a Teams app to get the attachment of a message (from a channel, conversation, personal) and send it to a web service somewhere else.
From a message extension action, I can get the following data.
This is from the activity.
{
commandId: 'CustomForm',
commandContext: 'message',
requestId: 'cf6747b9-bb94-4a70-87d1-d89834e33757',
messagePayload: {
linkToMessage: 'https://teams.microsoft.com/l/message/19:a841a46f-80f6-41cd-8717-7e41d6817195_af24b8a2-cfe8-453a-a9b4-4a917b1534ae@unq.gbl.spaces/1663342621107?context=%7B%22contextType%22:%22chat%22%7D',
id: '1663342621107',
replyToId: null,
createdDateTime: '2022-09-16T15:37:01.107Z',
lastModifiedDateTime: null,
deleted: false,
subject: null,
summary: null,
importance: 'normal',
locale: 'en-us',
body: {
contentType: 'html',
content: '<p>test attach pdf</p><attachment id="0b922164-a59f-44bc-8a4d-a94ad77bf94c"></attachment>'
},
from: {
device: null,
conversation: null,
user: [Object],
application: null
},
reactions: [],
mentions: [],
attachments: [ [Object] ]
},
context: { theme: 'default' }
}
This is the content of attachments
{
id: '0b922164-a59f-44bc-8a4d-a94ad77bf94c',
contentType: 'reference',
contentUrl: 'https://xxwdq-my.sharepoint.com/personal/thehuy_xxwdq_onmicrosoft_com/Documents/Microsoft Teams Chat Files/PDF.PDF',
content: null,
name: 'PDF.PDF',
thumbnailUrl: null
}
I have an ID and the contentUrl. ContentUrl is not working because I'm accessing the file without the user credentials.
I found out online, the best way to access files is to use the MS Graph. I tried to use it in Postman, but I don't find out what endpoint to use and what parameter is what ?
Can somebody help me figure this out ?
Thanks.