How to send message with attachment to a PPTX document on Teams?

Daniel Rivers 1 Reputation point


I have an integration which uploads a file to the files tab of a channel and then posts to the channel with the file attached. While this works with PNG and PDF files, when I try to attach a PPTX file it errors with the exception File contentUrl extension: '.aspx?sourcedoc=%7B3A6A105C-FC33-4BA2-BD42-663E30AE891A%7D' and name extension: '.pptx' do not match.

This appears to be because the get driveItem is returning a aspx page for the webUrl. e.g. https://{sharepointurl}/sites/{site}/_layouts/15/Doc.aspx?sourcedoc=%7B3A6A105C-FC33-4BA2-BD42-663E30AE891A%7D

The documentation states: 'Note: The file must already be in SharePoint. To find the file properties, GET the driveItem for the file. For example, /drives/{id}/items/{id}. Your attachment ID is the GUID in the eTag of the driveItem, your attachment contentURL is the webUrl of the driveItem's folder plus the driveItem's name, and your attachment name is the driveItem's name.' this is the exact approach I am using. (

I am not sure how to get around this issue currently. I have been trying to investigate and get around the issue today with no success. Any guidance?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,553 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,836 questions
{count} votes