Retrieve the metadata for an Item on OneDrive by path or ID.
To call the get item metadata API, the user must have granted the application read access to the specified item.
GET /drive/items/{item-id}
GET /drive/root:/{item-path}
You can use the OData query parameters to restrict the shape of the objects returned from this call.
Name | Value | Description |
---|---|---|
if-none-match | etag | If this request header is included and the eTag (or cTag) provided matches the current tag on the file, an HTTP 304 Not Modified response is returned. |
Do not supply a request body with this method.
GET /drive/items/{item-id}
If successful, this method returns an driveItem resource in the response body.
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "0123456789abc",
"name": "example.xlsx",
"eTag": "123918093j1lk2jlkda",
"cTag": "k1ml4klkasljasidj1l2j34lkaslz",
"createdBy": { "user": { "id": "1234", "displayName": "Ryan Gregg" } },
"createdDateTime": "string (timestamp)",
"lastModifiedBy": { "user": { "id": "1234", "displayName": "Ryan Gregg" } },
"lastModifiedDateTime": "string (timestamp)",
"size": 1234,
"webUrl": "http://onedrive.com/...",
"parentReference": { "driveId": "12345", "id": "root", "path": "/drive/root:" },
"folder": { "childCount": 4 }
}
Note: The response object is truncated for clarity. All default properties will be returned from the actual call.
You can use the expand
query string
parameter to include the children of an item in the same call as retrieving the
metadata of an item.
GET /drive/items/root?expand=children
This call will return the item metadata and a list of children of the item. If the item has no children, it will return an empty collection.
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "101230100alkc",
"name": "OneDrive",
"children": [
{ "id": "120100abo1", "name": "folder1", "folder": {} },
{ "id": "120100abab", "name": "file1.txt", "file": {} },
{ "id": "120100abo1", "name": "file2.txt", "folder": {} },
{ "id": "120100abo1", "name": "folder 2", "file": {} }
]
}
Note: Response objects are truncated for clarity. All default properties will be returned from the actual call.
In most cases, a HEAD request will behave the same way as a GET request. There are a couple differences:
- HEAD requests will only return the corresponding GET request's headers. This is standard practice for a HEAD response.
- HEAD requests will not automatically provision a
special folder. Instead, if a special folder is not present,
a
404
error will be returned.
In this example, you can see that requesting the root of your OneDrive will respond with
simply 200 OK
.
HEAD /drive/root
Accept: application/json
HTTP/1.1 200 OK
See Error Responses for more info about how errors are returned.