Skip to content

Latest commit

 

History

History
162 lines (121 loc) · 5.31 KB

File metadata and controls

162 lines (121 loc) · 5.31 KB
author spgraph-docs-team
description Create a new folder or DriveItem in a Drive with a specified parent item or path.
ms.date 09/10/2017
title Create a new folder
ms.localizationpriority medium
ms.subservice sharepoint
doc_type apiPageType

Create a new folder in a drive

Namespace: microsoft.graph

[!INCLUDE beta-disclaimer]

Create a new folder or DriveItem in a Drive with a specified parent item or path.

[!INCLUDE national-cloud-support]

Permissions

Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

[!INCLUDE permissions-table]

[!INCLUDE app-permissions]

HTTP request

POST /drives/{drive-id}/items/{parent-item-id}/children
POST /groups/{group-id}/drive/items/{parent-item-id}/children
POST /me/drive/items/{parent-item-id}/children
POST /sites/{site-id}/drive/items/{parent-item-id}/children
POST /users/{user-id}/drive/items/{parent-item-id}/children

Request body

In the request body, supply a JSON representation of the DriveItem resource to create.

Response

If successful, this method returns 201 Created response code and a Driveitem resource in the response body.

Example

Request

The following example shows a request to create a new folder in the signed-in user's OneDrive root folder. The @microsoft.graph.conflictBehavior property used indicates that if an item already exists with the same name, the service should choose a new name for the folder while creating it.

POST https://graph.microsoft.com/beta/me/drive/root/children
Content-Type: application/json

{
  "name": "New Folder",
  "folder": { },
  "@microsoft.graph.conflictBehavior": "rename"
}

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]


Response

If successful, this method returns the newly created folder as a DriveItem resource.

HTTP/1.1 201 Created
Content-Type: application/json

{
  "createdBy": {
    "user": {
      "displayName": "Ryan Gregg",
      "id": "309EC495-3E92-431D-9124-F0299633171D"
    }
  },
  "createdDateTime": "2016-09-20T14:34:00Z",
  "eTag": "343F1FBD-E9B3-4DDE-BCA7-D61AEAFF44E5,1",
  "id": "ACEA49D1-1444-45A9-A1CB-68B1B28AE491",
  "lastModifiedBy": {
    "user": {
      "displayName": "Ryan Gregg",
      "id": "309EC495-3E92-431D-9124-F0299633171D"
    }
  },
  "lastModifiedDateTime": "2016-09-20T14:34:00Z",
  "name": "New Folder",
  "parentReference": {
    "driveId": "5FE38E3C-051C-4D55-9B83-8A437658275B",
    "id": "E67A8F34-B0AA-46E1-8FF7-0750A29553DF",
    "path": "/drive/root:/"
  },
  "size": 0,
  "folder": {
    "childCount": 0
  }
}

Error response

See Error Responses for more info about how errors are returned.