Forum Discussion
Access_Jim
Jul 28, 2024Copper Contributor
Graph API with Large Attachment Problem
I am attempting to send an EMail via the O365 Graph API with a large attachment. I am doing this from Access VBA. I have created an upload session and am attempting to upload the attachment in ch...
Access_Jim
Jul 29, 2024Copper Contributor
Using the link you provided, it states: "As part of the response, this action returns an upload URL that you can use in subsequent sequential PUT queries." This is the part where I am having the problem. I have no problem creating the session. I am using https in my code.
Gerrit_Viehmann
Jul 29, 2024Copper Contributor
Access_Jim When you get a resonse similar to this:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.uploadSession",
"uploadUrl": "https://outlook.office.com/api/gv1.0/users('a8e8e219-4931-95c1-b73d-62626fd79c32@72aa88bf-76f0-494f-91ab-2d7cd730db47')/messages('AAMkAGUwNjQ4ZjIxLTQ3Y2YtNDViMi1iZjc4LTMA=')/AttachmentSessions('AAMkAGUwNjQ4ZjIxLTAAA=')?authtoken=eyJhbGciOiJSUzI1NiIsImtpZCI6IjFTeXQ1bXdXYVh5UFJ",
"expirationDateTime": "2024-07-30T14:20:12.9708933Z",
"nextExpectedRanges": [
"0-"
]
}
You store the value of uploadUrl for later use in PUTs and continue with 2 MiB chunks of the file as an answer similar to this:
PUT https://outlook.office.com/api/gv1.0/users('a8e8e219-4931-95c1-b73d-62626fd79c32@72aa88bf-76f0-494f-91ab-2d7cd730db47')/messages('AAMkAGUwNjQ4ZjIxLTQ3Y2YtNDViMi1iZjc4LTMA=')/AttachmentSessions('AAMkAGUwNjQ4ZjIxLTAAA=')?authtoken=eyJhbGciOiJSUzI1NiIsImtpZCI6IjFTeXQ1bXdXYVh5UFJ
Content-Type: application/octet-stream
Content-Length: 2097152
Content-Range: bytes 0-2097151/9483322
{
<bytes 0-2097151 of the file to be attached, in binary format>
}
and so on...