Copy an attachment file from outlook to onedrive using Ms Graph Api without download it

David DEL VECCHIO 21 Reputation points
2021-03-03T11:18:51.62+00:00

I have a robot that check email in outlook using Graph Api (v1).

I would like to copy the attachments files from the email on a onedrive folder without download it.

I know that i can use Flow to that, but it's no convenient for my task.

so i try that :

POST https://graph.microsoft.com/v1.0/me/drive/root/children Content-Type: application/json Prefer: respond-async

{  
"@microsoft.graph.fileAttachment": "https://graph.microsoft.com/v1.0/me/messages/{message_id}/Attachments/{attachment_id}/$value",  
"name": "test.pdf",  
"file": {}  
}  

This create the file but without the data inside... (0 byte file)

Ref : driveitem_upload_url
StackOverflow question : copy-an-attachment-file-from-outlook-to-onedrive-using-ms-graph-api-without-down

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

Accepted answer
  1. Danstan Onyango 3,736 Reputation points Microsoft Employee
    2021-03-09T18:16:15.02+00:00

    POST https://graph.microsoft.com/v1.0/me/drive/root/children Content-Type: application/json Prefer: respond-async

    Is for creating folder or item in a drive. I don't think it supports the file upload using url or attachment yet and am sure it is ignoring "@microsoft.graph.fileAttachment" in your request. I see a feature request for this here and I suggest you upvote that so that engineering team may implement it in future.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful