Reputation: 456
I can not upload large (more than 4Mb) attachment to an email created in a shared mailbox using Microsoft Graph. The steps that I followed are documented here but they did not work.
Creating draft (OK):
=> POST /users/[email protected]/mailFolders('drafts')/messages
{ message json }
<= 201
{ message json, id:"XXXX" }
Uploading small attachment (OK):
=> POST /users/[email protected]/messages/XXXX/attachments
{"contentBytes": "BASE64..." }
<= 201
{ attachment json }
Uploading large attachment (FAIL)
=> POST
/users/[email protected]/messages/XXXX/attachments/createUploadSession
{ AttachmentItem: { attachment json } }
<= 201
{ upload session json, uploadUrl: "https://outlook.office.com/api/beta/Users('guid@otherguid')/Messages('XXXX')?authtoken=SOME-JWT" }
=> PUT uploadUrl-from-above
attachment-body
<= 403
{
"error": {
"code":"ErrorAccessDenied",
"message":"Access is denied. Check credentials and try again."
}
}
I have requested the following permissions: user.read
, mail.readwrite
, mail.send
, mail.readwrite.shared
, mail.send.shared
. And an email with a small attachment is perfectly created in a shared mailbox.
How can I create an email with a large attachment in a shared mailbox via Microsoft Graph?
Upvotes: 1
Views: 282
Reputation: 33124
The createUploadSession
endpoint requires one of the following permission scopes: Files.ReadWrite
, Files.ReadWrite.All
, Sites.ReadWrite.All
.
Since this involves another user, I believe you'll need Files.ReadWrite.All
since Files.ReadWrite
only provides access to your own Drive.
Upvotes: 1