Skip to content

Latest commit

 

History

History
81 lines (62 loc) · 2.92 KB

copy.md

File metadata and controls

81 lines (62 loc) · 2.92 KB

Copy an Item on OneDrive (Preview)

Creates a copy of an [Item][item-resource] (including any children) on OneDrive, under a new parent.

Prerequisites

To call the copy API, the user must have granted the application read access to the specified item to be copied and write access to the destination folder.

HTTP request

POST /drive/items/{item-id}/action.copy
POST /drive/root:/{item-path}:/action.copy

Request body

In the request body, provide a JSON object that with the following parameters.

Name Value Description
parentReference ItemReference Reference to the parent item the copy will be created in.
name string Optional The new name for the copy. If this isn't provided, the same name will be used as the original.

Note: The parentReference should include either an id or path but not both. If both are included, they need to reference the same item or an error will occur.

Example

POST /drive/items/{item-id}/action.copy
Content-Type: application/json
Prefer: respond-async

{
  "parentReference": {
    "id": "{new-parent-id}",
    "path": "/drive/root:/Documents"
  },
  "name": "foobar"
}

Response

Returns details about how to monitor the progress of the copy, upon accepting the request.

HTTP/1.1 202 Accepted
Location: https://onedrive.com/monitor/113jlkjlkjasd1212abcascaf

The value of the Location header provides a URL for a service that will return the current state of the copy operation. You can use this info to determine when the copy has finished.

Error responses

To retrieve the current status of the async copy job, issue a GET request to the URL in the Location header. If the response returns an HTTP 202 then the body of the response is an AsyncJobStatus resource that defines the current status of the job.

If the copy job has completed, the GET request will return an HTTP 303 See Other response with a new Location header that will take you to the item resource for the copied item.

See [Error Responses][error-response] for more info about how errors are returned. [error-response]: ../misc/errors.md [item-resource]: ../resources/item.md