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 Item resource in the response body.
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "0123456789abc",
"name": "example.xlsx",
"eTag": "etag",
"cTag": "etag",
"createdBy": { "user": { "id": "1234", "displayName": "Ryan Gregg" } },
"createdDateTime": "datetime",
"lastModifiedBy": { "user": { "id": "1234", "displayName": "Ryan Gregg" } },
"lastModifiedDateTime": "datetime",
"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.
See Error Responses for more info about how errors are returned.