Get Attachment photo/video/file from conversation by attachment id or contentUrl

Aleksandr Yushko 1 Reputation point
2021-02-24T12:47:01.08+00:00

Hi All! Need Help!
We tried to receive attachment file when send conversation to other side but can't do it.
attempt 1(with graph client):
graphClient.me().messages("1614078832901").attachments("b7c5fd22-8b53-4528-8fe3-5d600471eeb8").buildRequest().get();
response status: 403.

attempt 2 (with Postman):
https://graph.microsoft.com/beta/me/messages/1614078832901/attachments/b7c5fd22-8b53-4528-8fe3-5d600471eeb8
Authorization Bearer {token}
response status: 403.

attempt 3 (with contentUrl):
https://dataart618.sharepoint.com/sites/test03/Shared Documents/General/a3411_lg.jpg
Authorization Bearer {token}
response status: 401.

All permissions was added from this doc: https://learn.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-1.0&tabs=http#example-9-get-the-mime-raw-contents-of-a-meeting-invitation-item-attachment-on-a-message

I read that your SDK did not support this functionality earlier. Is it possible now to get the attached file somehow? If not, when do you plan to implement this feature?

Thanks a lot!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,576 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Mamatha-MSFT 156 Reputation points
    2021-03-01T09:47:01.887+00:00

    Hi @Aleksandr Yushko , I tried to repro at my end using Graph API request it's working fine and I am getting attachment properties.

    GET https://graph.microsoft.com/v1.0/me/messages/{id}/attachments/{id}

    Could you please try again by giving correct Message Id and attachment Id.

    0 comments No comments

  2. Aleksandr Yushko 1 Reputation point
    2021-03-01T21:34:57.643+00:00

    ----------

    Hi, @Mamatha-MSFT .
    Are you tried to get attachments from Microsoft Teams?
    If yes, can you describe steps for getting attachment files and needed permissions?
    This API doesn't work for me:

    73165-photo-2021-03-01-23-17-35.jpg

    73119-photo-2021-03-01-23-20-15.jpg