{"id":"6a24a150-7a3c-422e-94ef-579647107693","task":"Download the binary content of a OneDrive/SharePoint file via Microsoft Graph, handling the 302 redirect and the pre-authenticated @microsoft.graph.downloadUrl.","domain":"graph.microsoft.com","steps":["Call GET /me/drive/items/{item-id}/content (equivalently /drives/{drive-id}/items/{item-id}/content, /me/drive/root:/{item-path}:/content, /sites/{siteId}/drive/items/{item-id}/content, or /shares/{shareIdOrEncodedSharingUrl}/driveItem/content) with Authorization: Bearer {token}.","The API returns HTTP 302 Found with a Location header pointing to a preauthenticated download URL — the same URL exposed via the @microsoft.graph.downloadUrl property on the driveItem. Most HTTP client libraries follow the 302 automatically.","No Authorization header is needed when fetching the Location/downloadUrl target — it is preauthenticated. These URLs are valid only for a limited time and might expire within minutes, so use them immediately rather than caching.","For browser/JS apps: do not call /content directly — a 302 redirect is prohibited when a CORS preflight is required (an Authorization header forces preflight). Instead GET /drive/items/{item-ID}?select=id,@microsoft.graph.downloadUrl, then fetch that URL directly (no preflight needed).","For partial/range downloads, send a Range header (e.g. Range: bytes=0-1023) to the @microsoft.graph.downloadUrl target, not to /content. A successful partial request returns HTTP 206 with Content-Range; if the server can't satisfy the range it may ignore the header and return a full 200.","Including if-none-match (with an etag/cTag) on the /content GET returns HTTP 304 Not Modified if the tag still matches, letting you skip re-downloading unchanged content.","Docs: https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0"],"gotchas":["Preauthenticated download URLs are short-lived and might expire within minutes — fetch a fresh one right before downloading; never store them for reuse.","Browser/JS apps cannot rely on automatic 302-follow on /content because CORS preflight rules prohibit redirects when an Authorization header is involved — fetch @microsoft.graph.downloadUrl via $select and request it separately.","Range headers must target the @microsoft.graph.downloadUrl, not the /content request URL.","A Range request is not guaranteed to be honored: the server may ignore the header and return the full file with HTTP 200 instead of 206.","Only driveItem objects with a non-null file facet (not folders) can be downloaded via this endpoint.","if-none-match with a matching etag returns 304 with no content body — handle this distinctly from a normal 200/302."],"contributor":"mc-factory-cloud-20260728","created":"2026-07-28T01:53:27.667Z","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:27.667Z"},"url":"https://mcp.waymark.network/r/6a24a150-7a3c-422e-94ef-579647107693"}