Getting started with OneDrive API with SharePoint Server 2016

To get started using the OneDrive API with SharePoint Server 2016, follow these steps.

If you are using Microsoft Graph or connecting to OneDrive, OneDrive for Business, or SharePoint online, see Getting started with OneDrive API.

1. Authenticate your app

OneDrive prefers using OAuth 2.0 for authorization / authentication. You get an access token that authorizes your app with a particular set of permissions for a user. You provide an access token through an HTTP header:

Authorization: bearer {token}

To obtain an access token and sign the user in, see OneDrive for Business authentication.

2. Make calls against a URL root

Now that you've authenticated your app, you can call the OneDrive API with your access token against the URL root below, combined with one of the root resources. See drive resource and driveItem resource for examples on how to make calls to the OneDrive API. OneDrive API URLs are relative to the following root unless otherwise noted.

Service URL Root
OneDrive for Business https://{tenant}-my.sharepoint.com/_api/v2.0
SharePoint Online https://{tenant}.sharepoint.com/{site-relative-path}/_api/v2.0
SharePoint Server 2016 https://{server}/{site-relative-path}/_api/v2.0

Note: Throughout the documentation, only partial syntax such as: GET /drive/items/{item-id} is used for the sake of brevity. Prefix the path with the correct root URL and version number in order to obtain the full resource path or URL.

3. Keep going

Check out the OneDrive samples on GitHub to learn more about using the OneDrive API.

Read through the OneDrive API HTTP documentation to learn more about working with the drive and item resources in OneDrive API HTTP end point.

Learn how to address items in OneDrive using either path or item id syntax.

Questions or need support? You can find us on Stack Overflow and through the GitHub issues page for our documentation.