title: Microsoft Graph API - Getting files by file path - 404 Not Found
body: <p>My app is using client_credentials, and is successfully consuming the Graph API on most calls.</p>
  
  <p>However, I have been attempting to get images from a sharepoint folder by path and filename:</p>
  
  <pre><code>https://graph.microsoft.com/v1.0/drive/root:/sites/folder1/folder2/folder3/folder4/photo.jpg
  </code></pre>
  
  <p>The appropriate headers are being set (authorization and accept).</p>
  
  <pre><code>httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + session["access_token"]);
  httpClient.DefaultRequestHeaders.Add("accept", "application/json; odata.metadata=minimal");
  </code></pre>
  
  <p>The request returns a 404 - Not found response.</p>
  
  <p>When I navigate to our sharepoint site, I can see the image fine so I can only assume the file path is correct:</p>
  
  <pre><code>https://ourcompany.sharepoint.com/sites/folder1/folder2/folder3/folder4/photo.jpg
  </code></pre>
  
  <p>Apologies, but I am new to Graph API and couldn't find anything referencing this in the documentation:</p>
  
  <p><a href="https://docs.microsoft.com/en-us/graph/api/resources/onedrive?view=graph-rest-1.0" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/graph/api/resources/onedrive?view=graph-rest-1.0</a></p>
  
  <p><strong>Path</strong><br>
  /me/drive/root:/path/to/file</p>
  
  <p><strong>Resource</strong>
  Access a DriveItem by path relative to the user's OneDrive root folder.</p>
  
  <p>Are there special permissions needed for this? I found something suggesting permissions might be required in azure portal but this is to do with azure active directory and I'm not sure if it will affect the graph API, as it was working OK, reading drives and drive items in sharepoint (by drive id and drive item id, not by file path).</p>
  
  <p>EDIT: Went into azure portal, added Graph API permissions to application:</p>
  
  <ul>
  <li>Site: ReadAll</li>
  <li>Directory: ReadAll</li>
  <li>File: ReadAll</li>
  </ul>
  
  <p>No change so far.</p>