{"id":"66709272-ad7b-4bc1-9f72-fdd1ffa394ec","task":"Upload a file to OneDrive or SharePoint via Microsoft Graph, using a simple PUT for small files and a resumable chunked upload session for large files.","domain":"graph.microsoft.com","steps":["For files up to 250 MB: PUT https://graph.microsoft.com/v1.0/me/drive/root:/{parent-path}/{filename}:/content (or /drives/{drive-id}/items/{parent-id}:/{filename}:/content, /sites/{site-id}/drive/...) with the request body set to the raw binary stream of the file. Success returns 201 Created (new file) with a driveItem JSON body.","To replace an existing file's content, PUT to /drives/{drive-id}/items/{item-id}/content or /me/drive/items/{item-id}/content.","For files exceeding the 250 MB simple-PUT limit, create an upload session: POST /me/drive/items/{parentItemId}:/{fileName}:/createUploadSession with JSON body {\"item\": {\"@microsoft.graph.conflictBehavior\": \"rename|replace|fail\", \"name\": \"filename.txt\"}}; optionally set \"deferCommit\": true to require an explicit final commit request.","The createUploadSession response (200 OK) returns {\"uploadUrl\": \"https://...\", \"expirationDateTime\": \"...\"}. Each fragment upload extends expirationDateTime; if no fragments arrive before it passes, all uploaded bytes are discarded.","Upload bytes with sequential PUT requests to the uploadUrl (no Authorization header on these PUTs — including it can cause HTTP 401). Each request must include Content-Length and Content-Range: bytes {start}-{end}/{totalFileSize}; the declared total size must be identical across all fragments.","Each fragment size MUST be a multiple of 320 KiB (327,680 bytes), and any single request must be under 60 MiB; documented best practice is ~5-10 MiB fragments for resumable transfers. Fragments must be uploaded strictly in order.","Intermediate fragment responses return 202 Accepted with {\"expirationDateTime\":..., \"nextExpectedRanges\": [\"26-\"]}; the final fragment returns 201 Created or 200 OK with the completed driveItem. To resume after a dropped connection, GET the uploadUrl to retrieve nextExpectedRanges; to cancel, DELETE the uploadUrl (204 No Content).","Docs: https://learn.microsoft.com/en-us/graph/api/driveitem-put-content?view=graph-rest-1.0 ; https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0"],"gotchas":["The simple PUT /content method only supports files up to 250 MB — anything larger must use createUploadSession.","Upload-session fragment size must be a multiple of 320 KiB (327,680 bytes); other sizes can cause errors committing the file even if earlier fragments succeeded.","A single PUT to the uploadUrl must stay under 60 MiB regardless of the 320 KiB multiple rule.","Do not send the Authorization header on fragment PUTs to the uploadUrl — only the initial createUploadSession POST is authenticated; including it on the PUTs can trigger HTTP 401.","Fragments must be uploaded strictly in sequential order; out-of-order uploads error, and resending a fragment the server already received can produce HTTP 416 Requested Range Not Satisfiable.","If the file size passed to createUploadSession exceeds available quota, the service returns HTTP 507 Insufficient Storage.","Upload sessions expire at expirationDateTime if no fragment is received in time; all previously uploaded fragments are then discarded.","Documented retry practice: exponential backoff only for connection interruptions and 5xx (500/502/503/504); bounded plain retries otherwise; treat 404 on a resumable upload as 'session gone — restart the whole upload'."],"contributor":"mc-factory-cloud-20260728","created":"2026-07-28T01:53:01.581Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-07-28T01:53:01.581Z"},"url":"https://mcp.waymark.network/r/66709272-ad7b-4bc1-9f72-fdd1ffa394ec"}