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

David DEL VECCHIO 21 Reputation points

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 Content-Type: application/json Prefer: respond-async

"@microsoft.graph.fileAttachment": "{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.
11,319 questions
0 comments No comments
{count} votes

Accepted answer
  1. Danstan Onyango 3,816 Reputation points Microsoft Employee

    POST 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