title: Microsoft Graph - Download content in one request
body: <p>I am using the following method in a web browser to fetch file contents of a DriveItem using the Microsoft Graph:</p>
  
  <pre><code>GET /drives/{drive-id}/items/{item-id}
  // Get the @microsoft.graph.downloadUrl property of the returned DriveItem
  GET {downloadUrl}
  </code></pre>
  
  <p>This requires two <code>GET</code> calls. </p>
  
  <p>I am also aware of this API:</p>
  
  <pre><code>GET /drives/{drive-id}/items/{item-id}/content
  </code></pre>
  
  <p>As documented here:</p>
  
  <p><a href="https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_get_content" rel="noreferrer" title="here">Download the contents of a DriveItem</a>. </p>
  
  <p>But the <code>/content</code> endpoint has two problems:</p>
  
  <ol>
  <li>It returns a 302 Found response, causing a redirect which needs another roundtrip to fetch the contents</li>
  <li>The API doesn't work in a JavaScript application using XHR as mentioned in this article: <a href="https://docs.microsoft.com/en-us/onedrive/developer/rest-api/concepts/working-with-cors" rel="noreferrer">OneDrive - CORS support</a></li>
  </ol>
  
  <p>How can I fetch the file contents of a DriveItem in one request?</p>