Files REST API reference

Last modified: June 30, 2015

Applies to: Office 365 | OneDrive for Business

The Files API represent a file storage and management API for SharePoint and OneDrive for Business. You can use the Files REST API or the client libraries, to work with OneDrive for Business files and folders. You can also try out the OneDrive API for both OneDrive and OneDrive for Business. Using the OneDrive API for OneDrive for Business however, is in preview. For production, please continue using the Files API.

The Files API supports OData V4, including the following features:

  • The service document ($metadata) is published at the service root.
  • Data is returned in one of the OData defined formats.

For more info about OData V4, see OData Version 4.0.

If you are developing an iOS or OSX app, you can use the Microsoft Azure Active Directory Authentication Library (ADAL) SDK for Objective-C, for authenticaton. If you are developing an Android app, you can use the Microsoft ADAL SDK for Android for authentication.

Note If you develop apps for Office 365 in China, see API endpoints of Office 365 for China for the specification of the required URLs.

All Files API operations

Files REST API operations

Create a folder | Get folder properties | List folder contents | Update folder properties | Copy a folder | Delete a folder | Create an empty file | Upload content for a file | Create a file with content | Download a file | Get file properties | Update file properties | Copy a file | Delete a file | Get drive properties

Files Client API operations

Get an access token | Get the SharePoint client | List folder contents | Copy a folder | Create a file | Download a file | Delete a file

Use the Files REST API

To access the Files REST API, you need to register your app in Microsoft Azure Active Directory, SharePoint, or a OneDrive for Business site, authenticate your app, and then get an access token. The next example shows how to format the access token:

Authorization:Bearer <access token>

For more info on how to get an access token, see Authorization Code Grand Flow. For more info on how to get started with Office 365, including how to get an Office 365 account and associate it with Azure AD, see Get set up.

You access the Files REST API by sending HTTP requests to a specific endpoint URL. You can also use the Discovery Service API to find endpoints for your Office 365 app.

The root URL is based on the host name of the server that serves as the REST endpoint. In this reference, root URLs are denoted by {base-url}, which represents one of the following:

  • OneDrive for Business: https://{tenant}-my.sharepoint.com/_api/v1.0/me

  • SharePoint sites: https://{tenant}.sharepoint.com/{site-path}/_api/v1.0

Note that /me represents the Microsoft.CoreServices.CurrentUserRequestContext namespace. This is used specifically for OneDrive for Business storage.

After you've set up a tenant, you can start making REST calls by using these methods:

  • GET - Get properties for a file, folder, or drive. You can also use GET to download a file's contents.

  • POST - Create a file, copy contents of a file or folder.

  • PATCH - Update properties of a file or folder. Move a file or folder.

  • PUT - Create a folder.

  • DELETE - Delete a file or folder.

Tip You can view the complete metadata document for the Files entity data model by going to https://{tenant}-my.sharepoint.com/_api/v1.0/$metadata.

API requests support two resource addressing options: ID-based and path-based. Both examples are provided in this reference.

Request and response bodies are sent and received in the form JSON objects. For details on error responses, see response errors.

The Files REST API supports batched requests to let you combine multiple requests in a single POST request against a batch request URL. A batch request URL is of the https://{base-url}/$batch format. Its content type is of the multipart/mixed MIME type. For programming details, see Make batch requests with the REST APIs.

See Programming notes for more information about the important programming details.

Use the Office 365 client library

The Office 365 APIs .NET and Cordova JavaScript client libraries can make it easier to interact with the REST APIs. They help manage authentication tokens, simplify the code needed to query and consume data, and perform discovery. You can get the libraries in the latest version of Office 365 API Tools for Visual Studio. To learn more, see Overview of developing on the Office 365 platform.

To access the Office 365 Files API by using the .NET or JavaScript client library, you need to acquire an access token and get the SharePoint client.

Get an access token

Acquire the access token to use for authentication. The client ID and authorization URI are assigned when you register your app with Microsoft Azure Active Directory.

Note This pattern applies only to code that runs on Windows devices. In a Windows Store app, values for ClientID and AuthorizationUri are added to your project's App.xaml file when you register your application. AuthorizationUri is used as the host name for the CommonAuthority variable.

Important The Discovery service no longer accepts tokens that were issued for the resource Microsoft.SharePoint. The supported resource for Discovery service is https://api.office.com/discovery/.

// Properties of the native client app. Get the ClientId from the resources section of the App.xaml file.
public const string ClientID = Application.Current.Resources["ida:ClientID"] as String;
// Get the returnUri from app settings.
public static Uri _returnUri = Windows.Security.Authentication.Web.WebAuthenticationBroker.GetCurrentApplicationCallbackUri();

// Properties used to communicate with a Windows Azure AD tenant.
public const string CommonAuthority = "https://login.windows.net/Common";
public const string DiscoveryResourceId = "https://api.office.com/discovery/";

// Store authority in application data so that it isn't tied to the lifetime of the access token.
private static ApplicationDataContainer _settings = ApplicationData.Current.LocalSettings;

private static string LastAuthority
{
    get
    {
        if (_settings.Values.ContainsKey("LastAuthority") && _settings.Values["LastAuthority"] != null)
        {
            return _settings.Values["LastAuthority"].ToString();
        }
        else
        {
            return string.Empty;
        }
    }

    set
    {
        _settings.Values["LastAuthority"] = values;
    }
}

public static AuthenticationContext _authenticationContext { get; set; }

private static async Task<string> GetTokenHelperAsync(AuthenticationContext context, string resourceId)
{
    string accessToken = null;
    AuthenticationResult result = null;

    result = await context.AcquireTokenAsync(resourceId, ClientID, _returnUri);

    accessToken = result.AccessToken;

    // Store authority in application data.
    _settings.Values["LastAuthority"] = context.Authority;

    return accessToken;
}
var authContext = new O365Auth.Context();

authContext.getIdToken("https://outlook.office365.com/")
.then((function (token) {
    // Save the token in authToken for later use.
    // Can use token.givenName and token.familyName.
}));

var accessToken = authContext.getAccessTokenFn('Microsoft.SharePoint');

Get the SharePoint client

Get the SharePointClient object. You can call this code from other methods that use the SharePoint client.

Important The Discovery service no longer accepts tokens that were issued for the resource Microsoft.SharePoint. The supported resource for Discovery service is https://api.office.com/discovery/.

public static async Task<SharePointClient> CreateSharePointClientAsync(string capability)
{
    try
    {
        //First, look for the authority used during the last authentication.
        //If that value is not populated, use CommonAuthority.
        string authority = null;
        if (String.IsNullOrEmpty(LastAuthority))
        {
            authority = CommonAuthority;
        }
        else
        {
            authority = LastAuthority;
        }
        // Create an AuthenticationContext using this authority.
        _authenticationContext = new AuthenticationContext(authority);

        //See the Discovery Service Sample (https://github.com/OfficeDev/Office365-Discovery-Service-Sample)
        //for an approach that improves performance by storing the discovery service information in a cache.
        DiscoveryClient discoveryClient = new DiscoveryClient(
            async () => await GetTokenHelperAsync(_authenticationContext, DiscoveryResourceId));

        // Get the specified capability ("MyFiles").
        CapabilityDiscoveryResult result =
            await discovery.DiscoverCapabilityAsync(capability);


        var client = new SharePointClient(
            result.ServiceEndpointUri,
            async () =>
                await GetTokenHelperAsync(_authenticationContext, result.ServiceResourceId));
        return client;
    }
    catch (Exception)
    {
        if (_authenticationContext != null && _authenticationContext.TokenCache != null)
            _authenticationContext.TokenCache.Clear();
        return null;
    }
}
var authContext = new O365Auth.Context();
var discoveryContext = new O365Discovery.Context();
var sharePointClient;
discoveryContext.services(authContext.getAccessTokenFn('Microsoft.SharePoint')).then((function (capabilities) {
    capabilities.forEach(function (v, i, a) {
        if (v.capability === 'MyFiles') {
            sharePointClient = new Microsoft.CoreServices.SharePointClient(
            v.endpointUri,
            authContext.getAccessTokenFn(v.resourceId)
            );
            }
        });

    }).bind(this), function (error) {
        console.log(JSON.stringify(error));
});

Folder operations

A Folder resource represents a container of files and other folders. It is derived from the Item resource. Properties for a folder includes all Item properties, with the following additional properties.

PropertyTypeDescription
childCount64-bit intDirect children count of the folder. This property is available only if the type is Folder.
childrenItems collectionA collection of files and folders.

Request URL Parameters

NameTypeDescription
folder-idstringThe folder ID. The root folder can be addressed by using the root special ID.
parent-idstringThe ID of the parent folder. The root folder can be addressed by using the root special ID.
folder-namestringThe name of the folder.
folder-pathstringThe relative path of the folder.

Create a folder (REST)

Create a folder in the drive.

Using folder-id:

A folder can be created by specifying the parent folder ID and its children collection.

PUT {base-url}/Files/{parent-id}/children/{folder-name}

Using folder-path:

Specify the full path of the folder to be created.

Note: If one or more folders in the path is not present, they will be created as part of the same request.

PUT {base-url}/Files/getByPath('{folder-path}')

Sample request

PUT https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ/children/Test%203

Sample response

Status code: 201
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#SP.ApiData.Folders/$entity",
  "@odata.type": "#Microsoft.FileServices.Folder",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
  "@odata.etag": "\"{CA738782-EB7A-4763-B872-9F34BC9A45A9},1\"",
  "@odata.editLink": "files/01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
  "createdBy": {
    "application": {
      "id": "3123d3ed-aa21-4b08-9b1f-a16f231875d9",
      "displayName": "3123d3ed-aa21-4b08-9b1f-a16f231875d9@8cf2f73e-83b6-49e3-ad64-4adb999da1b7"
    },
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "eTag": "\"{CA738782-EB7A-4763-B872-9F34BC9A45A9},1\"",
  "id": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
  "lastModifiedBy": {
    "application": {
      "id": "3123d3ed-aa21-4b08-9b1f-a16f231875d9",
      "displayName": "3123d3ed-aa21-4b08-9b1f-a16f231875d9@8cf2f73e-83b6-49e3-ad64-4adb999da1b7"
    },
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "name": "test 2",
  "parentReference": {
    "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
    "id": "01J5374RT7GUQ3FOUVB5CJQYDUPOL2ZBFD",
    "path": "Test 1"
  },
  "size": 0,
  "dateTimeCreated": "2014-10-10T21:00:22Z",
  "dateTimeLastModified": "2014-10-10T21:00:22Z",
  "type": "Folder",
  "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Test%201/test%202",
  "childCount": 0
}

Sample request

PUT https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/getByPath('/Test%201/Test%202)

Sample response

Status code: 201
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#SP.ApiData.Folders/$entity",
  "@odata.type": "#Microsoft.FileServices.Folder",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
  "@odata.etag": "\"{CA738782-EB7A-4763-B872-9F34BC9A45A9},1\"",
  "@odata.editLink": "files/01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
  "createdBy": {
    "application": {
      "id": "3123d3ed-aa21-4b08-9b1f-a16f231875d9",
      "displayName": "3123d3ed-aa21-4b08-9b1f-a16f231875d9@8cf2f73e-83b6-49e3-ad64-4adb999da1b7"
    },
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "eTag": "\"{CA738782-EB7A-4763-B872-9F34BC9A45A9},1\"",
  "id": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
  "lastModifiedBy": {
    "application": {
      "id": "3123d3ed-aa21-4b08-9b1f-a16f231875d9",
      "displayName": "3123d3ed-aa21-4b08-9b1f-a16f231875d9@8cf2f73e-83b6-49e3-ad64-4adb999da1b7"
    },
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "name": "test 2",
  "parentReference": {
    "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
    "id": "01J5374RT7GUQ3FOUVB5CJQYDUPOL2ZBFD",
    "path": "Test 1"
  },
  "size": 0,
  "dateTimeCreated": "2014-10-10T21:00:22Z",
  "dateTimeLastModified": "2014-10-10T21:00:22Z",
  "type": "Folder",
  "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Test%201/test%202",
  "childCount": 0
}

Response type

A Folder resource if successful.

Get folder properties (REST)

Get a folder's properties.

Using folder-id:

GET {base-url}/Files/{folder-id}

Using folder-path:

GET {base-url}/getByPath('{folder-path}')

Optional query parameters

NameTypeDescription
$expandstringRelationships to expand and include in the response. For folders, you can expand on its children collection.
$selectstringA comma-separated list of properties to include in the response.

Request URL parameter

NameTypeDescription
if-none-matchetagIf this request header is included and the etag provided matches the current etag on the file, an HTTP 304 Not Modified response is returned. Optional.

Sample request

GET https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/root

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#files/$entity",
  "@odata.type": "#Microsoft.FileServices.Folder",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RV6Y2GOVW7725BZO354PWSELRRZ",
  "@odata.editLink": "files/01J5374RV6Y2GOVW7725BZO354PWSELRRZ",
  "createdBy": null,
  "eTag": null,
  "id": "01J5374RV6Y2GOVW7725BZO354PWSELRRZ",
  "lastModifiedBy": null,
  "name": "/",
  "parentReference": null,
  "size": 0,
  "dateTimeCreated": "2014-09-19T18:08:46Z",
  "dateTimeLastModified": "2014-10-22T12:04:20Z",
  "type": "Folder",
  "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents",
  "childCount": 13
}

Sample request

GET https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/getByPath('/Shared%20With%20Everyone')

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#files/$entity",
  "@odata.type": "#Microsoft.FileServices.Folder",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RTJSQOEUWQDHNHY7H5Y47ILXBPM",
  "@odata.etag": "\"{4A1C9469-035A-4F3B-8F9F-B8E7D0BB85EC},1\"",
  "@odata.editLink": "files/01J5374RTJSQOEUWQDHNHY7H5Y47ILXBPM",
  "createdBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "eTag": "\"{4A1C9469-035A-4F3B-8F9F-B8E7D0BB85EC},1\"",
  "id": "01J5374RTJSQOEUWQDHNHY7H5Y47ILXBPM",
  "lastModifiedBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "name": "Shared with Everyone",
  "parentReference": {
    "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
    "id": "01J5374RV6Y2GOVW7725BZO354PWSELRRZ",
    "path": "/"
  },
  "size": 0,
  "dateTimeCreated": "2014-09-19T18:12:25Z",
  "dateTimeLastModified": "2014-10-22T12:04:20Z",
  "type": "Folder",
  "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Shared%20with%20Everyone",
  "childCount": 1
}

Sample request

GET https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/01CNPZDU56Y2GOVW7725BZO354PWSELRRZ?$expand=children

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/$metadata#files/$entity",
  "@odata.type": "#Microsoft.FileServices.Folder",
  "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
  "@odata.editLink": "files/01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
  "createdBy": null,
  "eTag": null,
  "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
  "lastModifiedBy": null,
  "name": "/",
  "parentReference": null,
  "size": 0,
  "dateTimeCreated": "2014-10-08T19:05:49Z",
  "dateTimeLastModified": "2014-10-24T20:26:43Z",
  "type": "Folder",
  "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents",
  "childCount": 13,
  "children@odata.navigationLink": "files/01CNPZDU56Y2GOVW7725BZO354PWSELRRZ/children",
  "children": [
    {
      "@odata.type": "#Microsoft.FileServices.Folder",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDUZWETMJBPLOCFF2AUKCRLNA6THH",
      "@odata.etag": "\"{90D82436-6EBD-4B11-A051-428ADA0F4CE7},1\"",
      "@odata.editLink": "files/01CNPZDUZWETMJBPLOCFF2AUKCRLNA6THH",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{90D82436-6EBD-4B11-A051-428ADA0F4CE7},1\"",
      "id": "01CNPZDUZWETMJBPLOCFF2AUKCRLNA6THH",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Shared with Everyone",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 0,
      "dateTimeCreated": "2014-10-16T07:24:30Z",
      "dateTimeLastModified": "2014-10-16T07:25:07Z",
      "type": "Folder",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Shared%20with%20Everyone",
      "childCount": 1
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDUY4XUZOKTN2CVH3OGX2S3IHOEA6",
      "@odata.etag": "\"{E532BD1C-BA4D-4F15-B71A-FA96D077101E},1\"",
      "@odata.editLink": "files/01CNPZDUY4XUZOKTN2CVH3OGX2S3IHOEA6",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{E532BD1C-BA4D-4F15-B71A-FA96D077101E},1\"",
      "id": "01CNPZDUY4XUZOKTN2CVH3OGX2S3IHOEA6",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Ideas for XT1000 Series.docx",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 17775,
      "dateTimeCreated": "2014-10-16T07:24:56Z",
      "dateTimeLastModified": "2014-10-16T07:24:56Z",
      "type": "File",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Ideas%20for%20XT1000%20Series.docx",
      "contentUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01CNPZDUY4XUZOKTN2CVH3OGX2S3IHOEA6/content"
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDU4RBT2HWYZKXBBYS57UFXAMSLAP",
      "@odata.etag": "\"{7BF40C91-2A63-43B8-8977-F42DC0C92C0F},1\"",
      "@odata.editLink": "files/01CNPZDU4RBT2HWYZKXBBYS57UFXAMSLAP",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{7BF40C91-2A63-43B8-8977-F42DC0C92C0F},1\"",
      "id": "01CNPZDU4RBT2HWYZKXBBYS57UFXAMSLAP",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Marketing.pptx",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 151818,
      "dateTimeCreated": "2014-10-16T07:24:56Z",
      "dateTimeLastModified": "2014-10-16T07:24:56Z",
      "type": "File",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Marketing.pptx",
      "contentUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01CNPZDU4RBT2HWYZKXBBYS57UFXAMSLAP/content"
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDU3CKZNXW2KUBJE24SSBZT7JRC7Y",
      "@odata.etag": "\"{7B5B5662-5469-490A-AE4A-41CCFE988BF8},1\"",
      "@odata.editLink": "files/01CNPZDU3CKZNXW2KUBJE24SSBZT7JRC7Y",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{7B5B5662-5469-490A-AE4A-41CCFE988BF8},1\"",
      "id": "01CNPZDU3CKZNXW2KUBJE24SSBZT7JRC7Y",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Meeting Notes.docx",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 33432,
      "dateTimeCreated": "2014-10-16T07:24:56Z",
      "dateTimeLastModified": "2014-10-16T07:24:56Z",
      "type": "File",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Meeting%20Notes.docx",
      "contentUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01CNPZDU3CKZNXW2KUBJE24SSBZT7JRC7Y/content"
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDU5ZYKDIDG3GB5F2NCTPAWPLC2RG",
      "@odata.etag": "\"{8186C2B9-669B-4B0F-A68A-6F059EB16A26},1\"",
      "@odata.editLink": "files/01CNPZDU5ZYKDIDG3GB5F2NCTPAWPLC2RG",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{8186C2B9-669B-4B0F-A68A-6F059EB16A26},1\"",
      "id": "01CNPZDU5ZYKDIDG3GB5F2NCTPAWPLC2RG",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Proposal for Ad Campaign.docx",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 31853,
      "dateTimeCreated": "2014-10-16T07:24:57Z",
      "dateTimeLastModified": "2014-10-16T07:24:57Z",
      "type": "File",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Proposal%20for%20Ad%20Campaign.docx",
      "contentUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01CNPZDU5ZYKDIDG3GB5F2NCTPAWPLC2RG/content"
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDU3LPXSWE4ONFNE2LENQRQBR42BA",
      "@odata.etag": "\"{62E57D6B-CD71-492B-A591-B08C031E6820},1\"",
      "@odata.editLink": "files/01CNPZDU3LPXSWE4ONFNE2LENQRQBR42BA",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{62E57D6B-CD71-492B-A591-B08C031E6820},1\"",
      "id": "01CNPZDU3LPXSWE4ONFNE2LENQRQBR42BA",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Quick notes.txt",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 102,
      "dateTimeCreated": "2014-10-16T07:24:57Z",
      "dateTimeLastModified": "2014-10-16T07:24:57Z",
      "type": "File",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Quick%20notes.txt",
      "contentUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01CNPZDU3LPXSWE4ONFNE2LENQRQBR42BA/content"
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDUYJI5OMBJJSL5EI3YIOG4HRKEGN",
      "@odata.etag": "\"{C05C4709-32A5-485F-8DE1-0E370F1510CD},1\"",
      "@odata.editLink": "files/01CNPZDUYJI5OMBJJSL5EI3YIOG4HRKEGN",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{C05C4709-32A5-485F-8DE1-0E370F1510CD},1\"",
      "id": "01CNPZDUYJI5OMBJJSL5EI3YIOG4HRKEGN",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Shopping List.xlsx",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 15117,
      "dateTimeCreated": "2014-10-16T07:24:57Z",
      "dateTimeLastModified": "2014-10-16T07:24:57Z",
      "type": "File",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Shopping%20List.xlsx",
      "contentUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01CNPZDUYJI5OMBJJSL5EI3YIOG4HRKEGN/content"
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDUYR7NHOJUJSVZGYONEOTCHQ26HX",
      "@odata.etag": "\"{E44EFB11-32D1-4DAE-8734-8E988F0D78F7},1\"",
      "@odata.editLink": "files/01CNPZDUYR7NHOJUJSVZGYONEOTCHQ26HX",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{E44EFB11-32D1-4DAE-8734-8E988F0D78F7},1\"",
      "id": "01CNPZDUYR7NHOJUJSVZGYONEOTCHQ26HX",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Slogan Suggestions.docx",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 20020,
      "dateTimeCreated": "2014-10-16T07:24:57Z",
      "dateTimeLastModified": "2014-10-16T07:24:57Z",
      "type": "File",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Slogan%20Suggestions.docx",
      "contentUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01CNPZDUYR7NHOJUJSVZGYONEOTCHQ26HX/content"
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDUYRJEN3R3HDINBJR7UB5RO4SEUP",
      "@odata.etag": "\"{B81B4911-E3EC-4243-98FE-81EC5DC9128F},1\"",
      "@odata.editLink": "files/01CNPZDUYRJEN3R3HDINBJR7UB5RO4SEUP",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{B81B4911-E3EC-4243-98FE-81EC5DC9128F},1\"",
      "id": "01CNPZDUYRJEN3R3HDINBJR7UB5RO4SEUP",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Timesheet_Alexd.xlsx",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 18594,
      "dateTimeCreated": "2014-10-16T07:24:57Z",
      "dateTimeLastModified": "2014-10-16T07:24:57Z",
      "type": "File",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Timesheet_Alexd.xlsx",
      "contentUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01CNPZDUYRJEN3R3HDINBJR7UB5RO4SEUP/content"
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDUZKHZR2RYVXDZFLPUEAJVG5DFUU",
      "@odata.etag": "\"{A8633E2A-B7E2-4A1E-B7D0-804D4DD19694},1\"",
      "@odata.editLink": "files/01CNPZDUZKHZR2RYVXDZFLPUEAJVG5DFUU",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{A8633E2A-B7E2-4A1E-B7D0-804D4DD19694},1\"",
      "id": "01CNPZDUZKHZR2RYVXDZFLPUEAJVG5DFUU",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "XT1000 Series.pptx",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 82084,
      "dateTimeCreated": "2014-10-16T07:24:58Z",
      "dateTimeLastModified": "2014-10-16T07:24:58Z",
      "type": "File",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/XT1000%20Series.pptx",
      "contentUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01CNPZDUZKHZR2RYVXDZFLPUEAJVG5DFUU/content"
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDU4UC3ZPKGDPFNDY2K7WGPTFDVVT",
      "@odata.etag": "\"{F5F21694-6F18-472B-8D2B-F633E651D6B3},1\"",
      "@odata.editLink": "files/01CNPZDU4UC3ZPKGDPFNDY2K7WGPTFDVVT",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{F5F21694-6F18-472B-8D2B-F633E651D6B3},1\"",
      "id": "01CNPZDU4UC3ZPKGDPFNDY2K7WGPTFDVVT",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Ad Goals Presentation.pptx",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 82616,
      "dateTimeCreated": "2014-10-16T07:24:58Z",
      "dateTimeLastModified": "2014-10-16T07:24:58Z",
      "type": "File",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Ad%20Goals%20Presentation.pptx",
      "contentUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01CNPZDU4UC3ZPKGDPFNDY2K7WGPTFDVVT/content"
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDU4XC243RJP5B5EJNNXGYWIUTQP7",
      "@odata.etag": "\"{B8B91697-FDA5-480F-96B6-E6C59149C1FF},1\"",
      "@odata.editLink": "files/01CNPZDU4XC243RJP5B5EJNNXGYWIUTQP7",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{B8B91697-FDA5-480F-96B6-E6C59149C1FF},1\"",
      "id": "01CNPZDU4XC243RJP5B5EJNNXGYWIUTQP7",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Ad Goals.docx",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 21143,
      "dateTimeCreated": "2014-10-16T07:24:58Z",
      "dateTimeLastModified": "2014-10-16T07:24:58Z",
      "type": "File",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Ad%20Goals.docx",
      "contentUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01CNPZDU4XC243RJP5B5EJNNXGYWIUTQP7/content"
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849nda1-my.sharepoint.com/_api/v1.0/files/01CNPZDU6XVSTYPE4NXVAKJWN6EDZ532FY",
      "@odata.etag": "\"{87A7ACD7-8D93-40BD-A4D9-BE20F3DDE8B8},1\"",
      "@odata.editLink": "files/01CNPZDU6XVSTYPE4NXVAKJWN6EDZ532FY",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{87A7ACD7-8D93-40BD-A4D9-BE20F3DDE8B8},1\"",
      "id": "01CNPZDU6XVSTYPE4NXVAKJWN6EDZ532FY",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Annual Party Planning.docx",
      "parentReference": {
        "driveId": "01BRJ3DJHZNSWIIC6EYZB3DUY237SHZCOS",
        "id": "01CNPZDU56Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 19058,
      "dateTimeCreated": "2014-10-16T07:24:58Z",
      "dateTimeLastModified": "2014-10-16T07:24:58Z",
      "type": "File",
      "webUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Annual%20Party%20Planning.docx",
      "contentUrl": "https://a830edad9050849nda1-my.sharepoint.com/personal/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01CNPZDU6XVSTYPE4NXVAKJWN6EDZ532FY/content"
    }
  ]
}

Response type

The requested Folder resource (metadata) if successful.

List folder contents (REST)

List the contents of a folder. A folder can contain zero or more files or folders.

Using folder-id:

GET {base-url}/Files/{folder-id}/children

Using folder-path:

GET {base-url}/getByPath('{folder-path}')/children

Optional query parameters

NameTypeDescription
$filterstringFiltering based on the name parameter.
$orderbystringOrder by the name parameter.
$selectstringList of the properties that should be included for each item in the response.
$skipTokenstringPaging token.
$topstringDetermines the maximum number of records to return.

Request URL parameter

NameTypeDescription
if-non-matchetagIf this request header is included and the etag provided matches the current etag on the folder, an HTTP 304 Not Modified response is returned. Optional.

Sample request

GET https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/getByPath('Shared%20with%20Everyone')/children

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#files",
  "value": [
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ",
      "@odata.etag": "\"{74B3FC92-F342-4D98-8868-2072813540B0},1\"",
      "@odata.editLink": "files/01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{74B3FC92-F342-4D98-8868-2072813540B0},1\"",
      "id": "01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Denver Data.xlsx",
      "parentReference": {
        "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
        "id": "01J5374RTJSQOEUWQDHNHY7H5Y47ILXBPM",
        "path": "/Shared with Everyone"
      },
      "size": 23373,
      "dateTimeCreated": "2014-10-22T12:04:20Z",
      "dateTimeLastModified": "2014-10-22T12:04:20Z",
      "type": "File",
      "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Shared%20with%20Everyone/Denver%20Data.xlsx",
      "contentUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ/content"
    }
  ]
}

Sample request

GET https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/root/children

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#files",
  "@odata.nextLink": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files('root')/children?%24skiptoken=Paged%3dTRUE%26p_SortBehavior%3d0%26p_ID%3d50%26RootFolder%3d%252fpersonal%252fAlex D%255ftechedairlift05%255fccsctp%255fnet%252fDocuments&amp;%24&amp;select=name%2cid",
  "value": [
    {
      "@odata.type": "#Microsoft.FileServices.Folder",
      "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RTJSQOEUWQDHNHY7H5Y47ILXBPM",
      "@odata.etag": "\"{4A1C9469-035A-4F3B-8F9F-B8E7D0BB85EC},1\"",
      "@odata.editLink": "files/01J5374RTJSQOEUWQDHNHY7H5Y47ILXBPM",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{4A1C9469-035A-4F3B-8F9F-B8E7D0BB85EC},1\"",
      "id": "01J5374RTJSQOEUWQDHNHY7H5Y47ILXBPM",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Shared with Everyone",
      "parentReference": {
        "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
        "id": "01J5374RV6Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 0,
      "dateTimeCreated": "2014-09-19T18:12:25Z",
      "dateTimeLastModified": "2014-10-22T12:04:20Z",
      "type": "Folder",
      "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Shared%20with%20Everyone",
      "childCount": 1
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RXMYRD33SMHIFCYFVEAMQ3HJZYX",
      "@odata.etag": "\"{BD47C4EC-87C9-4541-82D4-80643674E717},1\"",
      "@odata.editLink": "files/01J5374RXMYRD33SMHIFCYFVEAMQ3HJZYX",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{BD47C4EC-87C9-4541-82D4-80643674E717},1\"",
      "id": "01J5374RXMYRD33SMHIFCYFVEAMQ3HJZYX",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Ad Goals Presentation.pptx",
      "parentReference": {
        "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
        "id": "01J5374RV6Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 82616,
      "dateTimeCreated": "2014-10-22T12:04:06Z",
      "dateTimeLastModified": "2014-10-22T12:04:06Z",
      "type": "File",
      "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Ad%20Goals%20Presentation.pptx",
      "contentUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01J5374RXMYRD33SMHIFCYFVEAMQ3HJZYX/content"
    },
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RUYG4GVQAJSLFAK7VAT3SGPDANG",
      "@odata.etag": "\"{580D3798-3201-4059-AFD4-13DC8CF181A6},1\"",
      "@odata.editLink": "files/01J5374RUYG4GVQAJSLFAK7VAT3SGPDANG",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{580D3798-3201-4059-AFD4-13DC8CF181A6},1\"",
      "id": "01J5374RUYG4GVQAJSLFAK7VAT3SGPDANG",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Ad Goals.docx",
      "parentReference": {
        "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
        "id": "01J5374RV6Y2GOVW7725BZO354PWSELRRZ",
        "path": "/"
      },
      "size": 21143,
      "dateTimeCreated": "2014-10-22T12:04:06Z",
      "dateTimeLastModified": "2014-10-22T12:04:06Z",
      "type": "File",
      "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Ad%20Goals.docx",
      "contentUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01J5374RUYG4GVQAJSLFAK7VAT3SGPDANG/content"
    }
  ]
}

Response type

The Children collection of child File and Folder resources if successful.

List folder contents (Client)

Get a list of all files and folders in the default document library. You can use either the folder ID (GetById) or relative folder path (GetByPathAsync) to get the contents of another folder.

This example calls the method that creates the SharePoint client.

var sharePointClient = await CreateSharePointClientAsync("MyFiles");
var files = await sharePointClient.Files.ExecuteAsync();

foreach(var file in files.CurrentPage)
{
  System.Diagnostics.Debug.WriteLine("{0} '{1}'", file.Type, file.Name);
}
sharePointClient.files.getItems().fetch().then(function (result) {
    result.currentPage.forEach(function (item) {
        console.log(item.type + ' "' + item.name + '"');
    });
}, function (error) {
    console.log(error)
});

Update folder properties (REST)

Update properties for an existing folder. Folders can be renamed by setting a new value for the folder's name property. You can also move the folder and its contents to another location by updating the ID or path of the parent folder.

Using folder-id:

PATCH {base-url}/Files/{folder-id}

Using folder-path:

PATCH {base-url}/Files/getByPath('{folder-path}')

Request URL parameters

NameTypeDescription
if-matchetagIf this request header is included and the etag provided does not match the current etag on the folder, an HTTP 412 Precondition Failed response is returned. Optional.

Request body parameters

In the request body, provide the values for the fields that you want to update. Don't include existing values that have not changed. Existing properties that aren't included in the request body request will maintain their previous values or be recalculated based on changes to other property values.

For move operations, you must provide either parentInfo.id or parentInfo.path but not both.

NameTypeDescription
namestringThe name of the folder. Set this property to a new value to rename the folder.
parentInfo.idstringThe ID of the parent folder to move the folder to.
parentInfo.pathstringThe path of the parent folder to move the folder to.

Sample request

PATCH https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/01J5374RUCQ5Z4U6XLMND3Q4U7GS6JJUHB
{
  "parentReference": {
    "id": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ"
  }
}

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#SP.ApiData.Folders/$entity",
  "@odata.type": "#Microsoft.FileServices.Folder",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RW6TUM5P6Q25RDITP7RSKVZYWMU",
  "@odata.etag": "\"{D7199DDE-1AFA-46EC-89BF-F192AB9C5994},1\"",
  "@odata.editLink": "files/01J5374RW6TUM5P6Q25RDITP7RSKVZYWMU",
  "createdBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "eTag": "\"{D7199DDE-1AFA-46EC-89BF-F192AB9C5994},1\"",
  "id": "01J5374RW6TUM5P6Q25RDITP7RSKVZYWMU",
  "lastModifiedBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "name": "Sample  Folder",
  "parentReference": {
    "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
    "id": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
    "path": "Test 1/test 2"
  },
  "size": 0,
  "dateTimeCreated": "2014-10-10T21:27:21Z",
  "dateTimeLastModified": "2014-10-10T21:29:40Z",
  "type": "Folder",
  "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Test%201/test%202/Sample%20Folder",
  "childCount": 0
}

Sample request

PATCH https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/getByPath('/Test%201/Sample%20Folder')
{
  "parentReference": {
    "path": "/Test%201/test%202"
  }
}

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#SP.ApiData.Folders/$entity",
  "@odata.type": "#Microsoft.FileServices.Folder",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RW6TUM5P6Q25RDITP7RSKVZYWMU",
  "@odata.etag": "\"{D7199DDE-1AFA-46EC-89BF-F192AB9C5994},1\"",
  "@odata.editLink": "files/01J5374RW6TUM5P6Q25RDITP7RSKVZYWMU",
  "createdBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "eTag": "\"{D7199DDE-1AFA-46EC-89BF-F192AB9C5994},1\"",
  "id": "01J5374RW6TUM5P6Q25RDITP7RSKVZYWMU",
  "lastModifiedBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "name": "Sample  Folder",
  "parentReference": {
    "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
    "id": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
    "path": "Test 1/test 2"
  },
  "size": 0,
  "dateTimeCreated": "2014-10-10T21:27:21Z",
  "dateTimeLastModified": "2014-10-10T21:29:40Z",
  "type": "Folder",
  "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Test%201/test%202/Sample%20Folder",
  "childCount": 0
}

Response type

The Folder resource (metadata) if successful.

Copy a folder (REST)

Copies all of the properties of a specified folder.

Using folder-id:

POST {base-url}/Files/{folder-id}/copy

Using folder-path:

POST {base-url}/getByPath('{folder-path}')/copy

Request URL parameters

NameTypeDescription
destFolderIdstringThe ID of the destination folder to create the copy in.
destFolderPathstringThe path of the destination folder to create the copy in.
newNamestringThe new name of the copied file. If this isn't provided, the original file name will be used.

Note Provide destFolderId or destPath but not both.

Sample request

POST https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/01J5374RUCQ5Z4U6XLMND3Q4U7GS6JJUHB/copy
{
  "destFolderId": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ"
}

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#SP.ApiData.Folders/$entity",
  "@odata.type": "#Microsoft.FileServices.Folder",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RW6TUM5P6Q25RDITP7RSKVZYWMU",
  "@odata.etag": "\"{D7199DDE-1AFA-46EC-89BF-F192AB9C5994},1\"",
  "@odata.editLink": "files/01J5374RW6TUM5P6Q25RDITP7RSKVZYWMU",
  "createdBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "eTag": "\"{D7199DDE-1AFA-46EC-89BF-F192AB9C5994},1\"",
  "id": "01J5374RW6TUM5P6Q25RDITP7RSKVZYWMU",
  "lastModifiedBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "name": "Sample  Folder",
  "parentReference": {
    "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
    "id": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
    "path": "Test 1/test 2"
  },
  "size": 0,
  "dateTimeCreated": "2014-10-10T21:27:21Z",
  "dateTimeLastModified": "2014-10-10T21:29:40Z",
  "type": "Folder",
  "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Test%201/test%202/Sample%20File1.docx",
  "childCount": 0
}

Sample request

POST https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/getByPath('/Sample%20Folder')/copy
{
  "destFolderPath": "/test%201/test%202"
}

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#SP.ApiData.Folders/$entity",
  "@odata.type": "#Microsoft.FileServices.Folder",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RW6TUM5P6Q25RDITP7RSKVZYWMU",
  "@odata.etag": "\"{D7199DDE-1AFA-46EC-89BF-F192AB9C5994},1\"",
  "@odata.editLink": "files/01J5374RW6TUM5P6Q25RDITP7RSKVZYWMU",
  "createdBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "eTag": "\"{D7199DDE-1AFA-46EC-89BF-F192AB9C5994},1\"",
  "id": "01J5374RW6TUM5P6Q25RDITP7RSKVZYWMU",
  "lastModifiedBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "name": "Sample  Folder",
  "parentReference": {
    "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
    "id": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
    "path": "Test 1/test 2"
  },
  "size": 0,
  "dateTimeCreated": "2014-10-10T21:27:21Z",
  "dateTimeLastModified": "2014-10-10T21:29:40Z",
  "type": "Folder",
  "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Test%201/test%202/Sample%20File1.docx",
  "childCount": 0
}

Response type

The copied Folder resource if successful.

Copy a folder (Client)

Copy a file or folder to a different folder. Call CopyAsync on the file or folder and pass in the destination path or the destination ID and an optional new name.

This example assumes you already got the SharePoint client and the folder Id or path.

// Specify a folder ID and a new name.
await sharePointClient.Files.GetById(fileId).ToFile().CopyAsync(folderId, null, "TODO.txt");

// Specify a folder path.
await sharePointClient.Files.GetById(fileId).ToFile().CopyAsync(null, "/Save", null);

Delete a folder (REST)

Delete the folder and all its contents.

Note Be careful when you delete folders. The folder, all subfolders, and all contents within the folders will be soft deleted. If deleted item retention is not enabled, the contents might not be recoverable.

Using folder-id:

DELETE {base-url}/Files/{folder-id}

Using folder-path:

DELETE {base-url}/getByPath('{folder-path}')

Request URL parameters

NameTypeDescription
if-matchetagIf this request header is included and the etag provided does not match the current etag on the folder, an HTTP 412 Precondition Failed response is returned. Optional.

Sample request

DELETE https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/01J5374RSPSWG2Z3ADOBBYL7YIXABA6KDU

Sample response

Status code: 204
{}

File operations

A File resource represents the contents of a document, photo, video, or other file type. It is derived from the Item resource. Properties for a file includes all Item properties, with the following additional properties.

PropertyTypeDescription
contentUrlstringURL for downloading the file's content.
imageImageFacetImage metadata, if the file is an image. To get ImageFacet properties, use the $select query parameter in the request URL to include specific properties in the response.

Request URL parameters

NameTypeDescription
file-idstringThe file ID.
file-namestringThe file name.
file-pathstringThe path of the file from the root folder.
parent-idstringThe ID of the parent folder. The root folder can be addressed by using the root special ID.

Create an empty file (REST)

Note: To create a file, you first create an empty file, and then upload its contents.

To create an empty file, use the following request:

POST {base-url}/Files/

Request URL parameters

NameTypeDescription
namestringThe name of the new file. Required.
typestringThe file type. Required.

Example request

The following example creates an empty file in the user's OneDrive for Business, called newFile.txt.

POST https://www.example.com/_api/v1.0/me/files
Content-Type: application/json
{
  "name" : "newFile.txt",
  "type" : "File"
}

Upload content for a file (REST)

Update a file by uploading content for the file. This request assumes that the file already exists.

Using file-id:

POST {base-url}/Files/{file-id}/uploadContent

Using file-path:

POST {base-url}/Files/getByPath('{file-path}')/uploadContent

Request body

Content of the file.

Note: Depending on how large the content is, content upload may take several minutes or time out.

Response type

Upon success, returns the File (metadata only) in the response body.

Create a file with content (REST)

Create a file in a user's OneDrive for Business by using the add action. You can use this request when you would like to upload an existing file. However, this request will also create a file, if the file doesn't already exist.

POST {baseURL}/Files/{parent-id}/children/add

Request URL parameters

NameTypeDescription
pathstringThe name of the new file. Required.
nameConflictstringDetermines what to do if a file with a matching file name already exists in this folder. Accepted values are: "overwrite" and "abort" (default). Required.
typestringThe file type. Required.

Request body

Content of the file.

Response type

Upon success, returns the File resource (metadata only) in the response body.

Create a file (Client)

Create an empty file with the specified name and then add content to the file, by using the Client API. This example assumes you already got the SharePoint client. It creates a file in the root folder.

MemoryStream fileContent = new MemoryStream(Encoding.UTF8.GetBytes("File contents here."));
Microsoft.Office365.SharePoint.FileServices.File newFile = new Microsoft.Office365.SharePoint.FileServices.File
{
    Name = "Test.txt"
};
await sharePointClient.Files.AddItemAsync(newFile);
await sharePointClient.Files.GetById(newFile.Id).ToFile().UploadAsync(fileContent);

Update the content of an existing file with the content provided as a bit stream. This example assumes you already got the SharePoint client and the file ID.

MemoryStream fileContent = new MemoryStream(Encoding.UTF8.GetBytes("Updated contents here."));
await sharePointClient.Files.GetById(fileId).ToFile().UploadAsync(fileContent);

Download a file (REST)

Download the original file content.

Using file-id:

GET {base-url}/Files/{file-id}/content

Using file-path:

GET {base-url}/getByPath('{file-path}')/content

Request URL parameters

NameTypeDescription
if-none-matchetagIf this request header is included and the etag provided matches the current etag on the file, an HTTP 304 Not Modified response is returned. Optional.

Response type

The File content if successful.

Download a file (Client)

You can download and read files by using the Client API. This example assumes you already got the SharePoint client and the file ID.

Stream stream = await sharePointClient.Files.GetById(fileId).ToFile().DownloadAsync();

// Read the file and convert the content to a string.
StreamReader reader = new StreamReader(stream);
string fileContentString = await reader.ReadToEndAsync();

Get file properties (REST)

Get properties for a File. This API does not return the file's content.

Using file-id:

GET {base-url}/files/{file-id}

Using file-path:

GET {base-url}/getByPath('{file-path}')

Optional query parameters

NameTypeDescription
expandstringA comma-separated list of relationships to expand and include in the response.
selectstringA comma-separated list of properties to include in the response.

Request URL parameter

NameTypeDescription
if-none-matchetagIf this request header is included and the etag provided matches the current etag on the file, an HTTP 304 Not Modified response is returned. Optional.

Response type

The File resource (metadata) if successful.

Note that addressing arbitrary properties or facets through the URL is not supported. The default response only includes properties of the Item resource. To retrieve specific properties for any Dependent resource, use the $select query parameter with specific properties to return in the response.

Sample request

GET https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/01CNPZDUZWETMJBPLOCFF2AUKCRLNA6THH

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#files",
  "value": [
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ",
      "@odata.etag": "\"{74B3FC92-F342-4D98-8868-2072813540B0},1\"",
      "@odata.editLink": "files/01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{74B3FC92-F342-4D98-8868-2072813540B0},1\"",
      "id": "01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Denver Data.xlsx",
      "parentReference": {
        "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
        "id": "01J5374RTJSQOEUWQDHNHY7H5Y47ILXBPM",
        "path": "/Shared with Everyone"
      },
      "size": 23373,
      "dateTimeCreated": "2014-10-22T12:04:20Z",
      "dateTimeLastModified": "2014-10-22T12:04:20Z",
      "type": "File",
      "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Shared%20with%20Everyone/Denver%20Data.xlsx",
      "contentUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ/content"
    }
  ]
}

Sample request

GET https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/GetByPath('shared%20with%20everyone/Denver%20Data.xlsx')

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#files",
  "value": [
    {
      "@odata.type": "#Microsoft.FileServices.File",
      "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ",
      "@odata.etag": "\"{74B3FC92-F342-4D98-8868-2072813540B0},1\"",
      "@odata.editLink": "files/01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ",
      "createdBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "eTag": "\"{74B3FC92-F342-4D98-8868-2072813540B0},1\"",
      "id": "01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ",
      "lastModifiedBy": {
        "application": null,
        "user": {
          "id": null,
          "displayName": "Alex D"
        }
      },
      "name": "Denver Data.xlsx",
      "parentReference": {
        "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
        "id": "01J5374RTJSQOEUWQDHNHY7H5Y47ILXBPM",
        "path": "/Shared with Everyone"
      },
      "size": 23373,
      "dateTimeCreated": "2014-10-22T12:04:20Z",
      "dateTimeLastModified": "2014-10-22T12:04:20Z",
      "type": "File",
      "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Shared%20with%20Everyone/Denver%20Data.xlsx",
      "contentUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ/content"
    }
  ]
}

Sample request

GET https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/01CNPZDUZWETMJBPLOCFF2AUKCRLNA6THH?$select=name,contenturl,size

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#files/$entity",
  "@odata.type": "#Microsoft.FileServices.File",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ",
  "@odata.etag": "\"{74B3FC92-F342-4D98-8868-2072813540B0},1\"",
  "@odata.editLink": "files/01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ",
  "name": "Denver Data.xlsx",
  "size": 23373,
  "contentUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01J5374RUS7SZXIQXTTBGYQ2BAOKATKQFQ/content"
}

Update file properties (REST)

Update properties for an existing file. Files can be renamed by setting a new value for the file's name property. You can also move the file to another location by updating the parent ID or path of the parent folder.

Using file-id:

PATCH {base-url}/files/{file-id}

Using file-path:

PATCH {base-url}/getByPath('{file-path}')

Request URL parameter

NameTypeDescription
if-matchetagIf this request header is included and the etag provided does not match the current etag on the file, an HTTP 412 Precondition Failed response is returned. Optional.

Request body parameters

In the request body, provide the values for the fields that you want to update. Don't include existing values that have not changed. Existing properties that are not included in the request body request will maintain their previous values or be recalculated based on changes to other property values.

For move operations, note that you must provide either parentInfo.id or parentInfo.path but not both.

NameTypeDescription
namestringThe name of the file. Set this property to a new value to rename the file.
parentInfo.idstringThe ID of the parent folder to move the file to.
parentInfo.pathstringThe path of the parent folder to move the file to.

Sample request

PATCH https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/01J5374RUCQ5Z4U6XLMND3Q4U7GS6JQWHJ
{
  "parentReference": {
    "id": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ"
  }
}

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#SP.ApiData.Files/$entity",
  "@odata.type": "#Microsoft.FileServices.File",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK",
  "@odata.etag": "\"{646B551A-0293-46CA-AD5C-1E1DC2595A0A},1\"",
  "@odata.editLink": "files/01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK",
  "createdBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "eTag": "\"{646B551A-0293-46CA-AD5C-1E1DC2595A0A},1\"",
  "id": "01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK",
  "lastModifiedBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "name": "Sample Upload.txt",
  "parentReference": {
    "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
    "id": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
    "path": "Test 1/test 2"
  },
  "size": 32,
  "dateTimeCreated": "2014-10-10T21:10:22Z",
  "dateTimeLastModified": "2014-10-10T21:34:41Z",
  "type": "File",
  "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Test%201/test%202/Sample%20Upload.txt",
  "contentUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK/content"
}

Sample request

PATCH https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/getByPath('/Test%201/Sample%20Upload.txt')
{
  "parentReference": {
    "path": "/Test%201/test%202"
  }
}

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#SP.ApiData.Files/$entity",
  "@odata.type": "#Microsoft.FileServices.File",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK",
  "@odata.etag": "\"{646B551A-0293-46CA-AD5C-1E1DC2595A0A},1\"",
  "@odata.editLink": "files/01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK",
  "createdBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "eTag": "\"{646B551A-0293-46CA-AD5C-1E1DC2595A0A},1\"",
  "id": "01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK",
  "lastModifiedBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "name": "Sample Upload.txt",
  "parentReference": {
    "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
    "id": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
    "path": "Test 1/test 2"
  },
  "size": 32,
  "dateTimeCreated": "2014-10-10T21:10:22Z",
  "dateTimeLastModified": "2014-10-10T21:34:41Z",
  "type": "File",
  "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Test%201/test%202/Sample%20Upload.txt",
  "contentUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK/content"
}

Response type

Upon success, returns the File resource (metadata only) in the response body.

Copy a file (REST)

Create a copy of the file contents to the specified location. If the new location is not specified, the file will be copied with the given new name in the same directory.

Using file-id:

POST {base-url}/files/{file-id}/copy

Using file-path:

POST {base-url}/getByPath('{file-path}')/copy

Request body parameters

NameTypeDescription
destFolderIdstringThe ID of the destination folder to create the copy in.
destFolderPathstringThe path of the destination folder to create the copy in.
newNamestringThe new name of the copied file. If this isn't provided, the original file name will be used.

Note Provide either destFolderID or destPath but not both.

Sample request

POST https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/01J5374RUCQ5Z4U6XLMND3Q4U7GS6JQWHJ/copy
{
  "newName": "Sample-Upload2.txt",
  "destFolderId": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ"
}

Sample response

Status code: 200
{
  "@odata.context": "https: //a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#SP.ApiData.Files/$entity",
  "@odata.type": "#Microsoft.FileServices.File",
  "@odata.id": "https: //a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK",
  "@odata.etag": "\"{646B551A-0293-46CA-AD5C-1E1DC2595A0A},1\"",
  "@odata.editLink": "files/01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK",
  "createdBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "AlexD"
    }
  },
  "eTag": "\"{646B551A-0293-46CA-AD5C-1E1DC2595A0A},1\"",
  "id": "01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK",
  "lastModifiedBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "AlexD"
    }
  },
  "name": "Sample-Upload2.txt",
  "parentReference": {
    "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
    "id": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
    "path": "Test1/test2"
  },
  "size": 32,
  "dateTimeCreated": "2014-10-10T21: 10: 22Z",
  "dateTimeLastModified": "2014-10-10T21: 34: 41Z",
  "type": "File",
  "webUrl": "https: //a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Test%201/test%202/Sample%20Upload.txt",
  "contentUrl": "https: //a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK/content"
}

Sample request

POST https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/getByPath('/Test%201/Sample%20Upload.txt')/copy
{
  "destFolderPath": "/test%201/test%202"
}

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#SP.ApiData.Files/$entity",
  "@odata.type": "#Microsoft.FileServices.File",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/files/01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK",
  "@odata.etag": "\"{646B551A-0293-46CA-AD5C-1E1DC2595A0A},1\"",
  "@odata.editLink": "files/01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK",
  "createdBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "eTag": "\"{646B551A-0293-46CA-AD5C-1E1DC2595A0A},1\"",
  "id": "01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK",
  "lastModifiedBy": {
    "application": null,
    "user": {
      "id": null,
      "displayName": "Alex D"
    }
  },
  "name": "Sample Upload.txt",
  "parentReference": {
    "driveId": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
    "id": "01J5374RUCQ5Z4U6XLMND3Q4U7GS6JURNJ",
    "path": "Test 1/test 2"
  },
  "size": 32,
  "dateTimeCreated": "2014-10-10T21:10:22Z",
  "dateTimeLastModified": "2014-10-10T21:34:41Z",
  "type": "File",
  "webUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/Documents/Test%201/test%202/Sample%20Upload.txt",
  "contentUrl": "https://a830edad9050849NDA1-my.sharepoint.com/alexd_a830edad9050849nda1_onmicrosoft_com/_api/v1.0/files/01J5374RQ2KVVWJEYCZJDK2XA6DXBFSWQK/content"
}

Response type

The copied File metadata properties if successful.

Delete a file (REST)

Delete a specified file. This operation moves the file to the recycle bin.

Using file-id:

DELETE {base-url}/files/{file-id}

Using path:

DELETE {base-url}/getByPath('{file-path}')

Request URL parameter

NameTypeDescription
if-matchetagIf this request header is included and the etag provided does not match the current etag on the file, an HTTP 412 Precondition Failed response is returned. Optional.

Response type Returns HTTP/1.1 204 No Content on success.

Sample request

DELETE https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/files/01J5374RSPSWG2Z3ADOBBYL7YIXABAMQ5I

Sample response

Status code: 204
{}

Delete a file (Client)

Delete a file using the Client API. This example assumes you already got the SharePoint client and the file ID.

IFile file = await sharePointClient.Files.GetById(fileId).ToFile().ExecuteAsync();
await file.DeleteAsync();

Drive operations

A Drive resource represents the root folder path in a user's endpoint URL. It provides information about the owner of the drive, total storage space, and available storage space. Its base class is Microsoft.FileServices.Drive. A drive is denoted by appending /drive to the endpoint URL. For example, https://{tenant}-my.sharepoint.com/_api/v1.0/me/drive.

PropertyTypeDescription
idstringThe unique identifier of an item in the drive.
ownerIdentityThe user account that owns the drive.
quotaDriveQuotaInformation about the drive's storage space quota.

Get drive properties (REST)

Get the properties for a drive.

GET {base-url}/drive

Sample request

GET https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/me/drive

Sample response

Status code: 200
{
  "@odata.context": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/$metadata#Drive/$entity",
  "@odata.type": "#Microsoft.FileServices.Drive",
  "@odata.id": "https://a830edad9050849NDA1-my.sharepoint.com/_api/v1.0/drive",
  "@odata.editLink": "drive",
  "id": "01OTIWNQQOTEPNCMVR3ZBZE7ZJTAODCBSU",
  "owner": {
    "id": "3",
    "displayName": "Alex D"
  },
  "quota": {
    "deleted": 698623,
    "remaining": 1099493380947,
    "state": "Ok",
    "total": 1099511627776
  }
}

Item resource

The Item resource represents an item in OneDrive for Business or SharePoint. Its base type is Microsoft.FileServices.Item.

PropertyTypeDescription
idstringThe unique identifier of the item within the drive.
namestringThe name of the item, in the form of file name and extension. Write access is allowed.
eTagstringETag for the entire item (metadata + content).
createdByIdentitySetIdentity of the user and application that created the item.
lastModifiedByIdentitySetIdentity of the user and application that last modified the item.
dateTimeCreatedtimestampDate and time the item was last modified. Represented using ISO 8601 format and is always in UTC time.
dateTimeLastModifiedtimestampDate and time the item was last modified. Represented using ISO 8601 format and is always in UTC time.
size64-bit integerSize of the item in bytes.
parentReferenceItemReferenceParent information, if the item has a parent.
webUrlstringURL that displays the resource in the browser.
typestringType of the resource. For a folder, the value is Folder. If the Item is a file, the value is File.

Dependent resources

IdentitySet | Identity | ItemReference | DriveQuota | ImageFacet

IdentitySet resource

PropertyTypeDescription
applicationIdentityApplication information.
userIdentityUser information.

Identity resource

PropertyTypeDescription
idstringThe unique identifier.
displayNamestringDisplayable name of the identity.

ItemReference resource

PropertyTypeDescription
driveIdstringDrive/me identifier.
idstringThe unique identifier.
pathstringFull path of the parent folder.

DriveQuota resource

PropertyTypeDescription
totalint64Total allowed storage space, in bytes.
remainingint64Total space remaining before hitting the quota limit, in bytes.
deletedint64Total space consumed by files in the recycle bin, in bytes.
statestringEnumerated value that indicates the state of the storage space. Possible values are ok, warning, and over.

ImageFacet resource

PropertyTypeDescription
dateTimeTakenDateTimeOffsetThe date and time the image was created.

Programming notes

X-HTTP-Method support | If-Match HTTP header | Case sensitivity | Encoding | Response errors

X-HTTP-Method support

You can instruct network intermediaries like proxies and firewalls to inspect traffic at the application protocol layer (for example, HTTP) and to block requests that contain certain HTTP verbs. In practice, GET and POST verbs are rarely blocked because traditional web pages rely heavily on these HTTP methods. However, other HTTP methods like PUT and DELETE are sometimes blocked by intermediaries for a variety of reasons, such as security vulnerabilities in prior protocols. Also, some HTTP libraries do not allow creation of requests that use verbs other than GET or POST. Therefore, you'll need an alternative way to specify request types that use verbs other than GET and POST to ensure that the patterns used in this reference work across a wide range of environments.

To address this need, you can add the X-HTTP-Method header to a POST request. This signals that the server must process the request not as a POST, but as if the HTTP verb specified was used as the method on the HTTP request line. This header is only valid on POST requests.

For example, the HTTP request in the following Delete Request Tunneled in a POST Request listing instructs the server to delete the identified resource, instead of performing an insert operation.

POST /Files/{id}
HTTP/1.1
Host: server
X-HTTP-Method: DELETE

If-Match HTTP header

The update and delete APIs require If-Match HTTP header to be provided with eTag of the resource in order to confirm that the client is modifying the resource from previously known state. A generic value of * could be provided to override the check. However it is not advised to override this option.


Case sensitivity

This section describes case-sensitivity rules for the Files API.

URL

The URL scheme, authority, and path (to the resource) information is treated as case insensitive. Depending on the type of resource addressing, the appropriate case handling needs to be taken into consideration.

ID-based addressing

The resource ID that is provided as part of the path is case sensitive. This is because the supplied ID is matched as-is against the OneDrive for Business resource listing.

Path-based addressing

The resource path that appears as part of URL is case insensitive.

Example: The path /Folder-A/Sample.txt is treated the same as /Folder-a/sample.TXT.

Query parameter

The request query parameter name value pairs are considered as case sensitive.

Request headers

Per HTTP 1.1 protocol, request header names are case insensitive. Example: Content-Type would be treated same as content-type.

The request header values can be case sensitive. Example: eTag values provided in if-match header.

JSON request body

The keys of the JSON object supplied in the request body are case sensitive. The value supplied in the name-value pair is stored in OneDrive for Business as-is (file or folder name).

JSON Response Body

In the JSON response, property names are camel-cased. The value of the property (such as the file or folder name) is returned as it is stored in OneDrive for Business.


Encoding

Encoding requirement applies to folder and file names in the URL and to the contents of a request body. The resource name and path might contain user-specified content which can include characters that are not URL safe, you must ensure proper encoding for any path segments.

The API expects that URLs conform to RFC 3986. The following is a summary of how to properly encode paths for the Files API. The Files API uses standard percent encoding, where invalid characters are encoded with a % and then the UTF-8 character code for the character. For example:

" " -> %20

"#" -> %23

In addition, the name or path information contained in request body should be valid JSON property values.

URI path characters

When constructing the path segment of a URL for the Files REST API, the following characters are allowed for path names:

  • pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
  • pct-encoded = "%" HEXDIG HEXDIG
  • unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
  • sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="

File or folder name characters which are not included in the pchar group, such as # and (space), must be percent encoded.

Response errors

Errors are returned as JSON objects in the response body.

{
    "error":
    {
        "code": "InvalidRequest",
        "message:"Cannot process the request",
    }
}
HTTP codeHTTP error messageError codeError message
400Bad RequestInvalidArgumentThe argument is invalid or missing or has an incorrect format.
400Bad RequestInvalidRequestCannot process the request.
400Bad RequeestPathContainsInvalidCharactersCannot parse the resource path.
401UnauthorizedUnauthenticatedRequired authentication information is either missing or invalid.
403ForbiddenAccessDeniedYou cannot perform the requested operation.
403ForbiddenNotAllowedThe request isn't allowed.
403ForbiddenVirusInfectedThe resource is infected with malware.
404Not FoundItemNotFoundThe requested resource doesn't exist.
406Not AcceptableFormatNotAcceptedThis service doesn't support the requested format.
409ConflictEditConflictRequest could not be processed because of conflict.
409ConflictFolderNotEmptyThe Delete If Empty flag is on and the Folder is not empty.
409ConflictNameAlreadyExistsA resource with the same name already exists.
411Length RequiredContentLengthRequiredA Content-Length header is required.
412Pre Condition FailedResourceModifiedThe server doesn't meet a requirement for the request.
413Request Entity Too LargeRequestTooLargeThe file size exceeds the maximum size.
416Requested Range Not SatisfiableInvalidRangeThe requested range is invalid.
429Too Many RequestsActivityLimitReachedActivity limit has been reached.
500Internal Server ErrorGeneralExceptionThere was an internal server error while processing the request.
501Not ImplementedNotImplementedThe requested feature isn't implemented.
503Service UnavailableServiceNotAvailableThe service is unavailable.
507Insufficient StorageQuotaLimitReachedThe maximum storage quota has been reached.

Next steps

Whether you're ready to start building an app or just want to learn more, we've got you covered.

Or, learn more about using the Office 365 platform: