With a Flow from Power Automate, I am sending a POST Request to send a chat message with a file attachment in a Team's channel in MS Teams as documented in the Graph API docs
It works well and I am able to get the message with a reference to the file in the channel as shown in the following picture :
Working sent message with attachment
The file is actually an attachment to a sharepoint item in a List that I am retrieving in the flow and sending back in the message with the correct ETag and absolute path as contentUrl:
The problem is the following: when I click on the file in the message, it does not display and an error message saying that the file might not exist anymore or that I do not have the right to access it appears (see next picture). Still, when I try to open the file in the browser (by right-clicking the file) it does open the url in the browser and download the file.
Error message in Teams after clicking on the file
What I would like: I would like that when I click on the file, it displays itself in Teams
What I've already tried:
- Sending the contentBytes as base64 of the attachment file with the contentType as MIME type of the file. --> Unfortunately, the request body is then not accepted. I think that the JSON schema is not respected because of contentBytes
- Checking if the file has the necessary rights and permission to be accessed
- Trying to use parameters at then end of the url like '?web=1'
None of the above allowed me to solve the problem. The nearest forum/discussion that I found about this problem is the following : https://docs.microsoft.com/en-us/answers/questions/335233/sorry-this-file-has-been-deleted-or-moved-teams-gr.html. Unfortunately the solution proposed (changing the attachment id with the sourcedoc id) did not work for me as I was unable to get the "sourcedoc" or "source ID" mentioned.