Skip to content

Commit 4c4c11d

Browse files
BarryShehadehMSFT-AndreaFaithOmbongi
authored
Add itemCount to List API [BETA] (#28278)
* add itemsCount * nit * Update whats-new-overview.md * Update list.md * Revise list-get.md with new examples and instructions Updated examples and request body instructions in the list-get documentation. * Modify request block type in list-get.md Updated the example request block type in the documentation. * Update whats-new-overview.md * Apply suggestion from @FaithOmbongi --------- Co-authored-by: MSFT-Andrea <v-andreadr@microsoft.com> Co-authored-by: Faith Moraa Ombongi <ombongi.moraa.fe@gmail.com>
1 parent 900af30 commit 4c4c11d

5 files changed

Lines changed: 50 additions & 21 deletions

File tree

api-reference/beta/api/list-get.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ GET /sites/{site-id}/lists/{list-id}?expand=columns,items(expand=fields)
3636

3737
## Request body
3838

39-
Do not supply a request body with this method.
39+
Don't supply a request body with this method.
4040

41-
## Example
41+
## Examples
4242

43+
### Example 1: Get list metadata by ID
44+
The following example shows how to get the metadata for a SharePoint list.
4345
#### Request
44-
46+
The following examples shows a request.
4547

4648
# [HTTP](#tab/http)
4749
<!-- { "blockType": "request", "name": "get-list-1" } -->
@@ -81,7 +83,7 @@ GET /sites/{site-id}/lists/{list-id}
8183
---
8284

8385
#### Response
84-
86+
The following examples shows the response.
8587
<!-- { "blockType": "response", "@type": "microsoft.graph.list", "truncated": true, "scopes": "sites.read.all service.sharepoint" } -->
8688

8789
```http
@@ -93,17 +95,18 @@ Content-type: application/json
9395
"name": "MicroFeed",
9496
"createdDateTime": "2016-08-30T08:32:00Z",
9597
"lastModifiedDateTime": "2016-08-30T08:32:00Z",
98+
"itemCount": 127,
9699
"list": {
97100
"hidden": false,
98101
"template": "genericList"
99102
}
100103
}
101104
```
102105

103-
With `select` and `expand` statements, you can retrieve list metadata, column definitions, and list items in a single request.
104-
105-
#### Request
106+
### Example 2: Get list metadata by title
106107
The following example shows how to get a list from a SharePoint Online list title.
108+
#### Request
109+
The following example shows a request.
107110

108111
# [HTTP](#tab/http)
109112
<!-- { "blockType": "request", "name": "get-list-2" } -->
@@ -143,7 +146,7 @@ GET /sites/{site-id}/lists/{list-title}
143146
---
144147

145148
#### Response
146-
149+
The following example shows the response.
147150
<!-- { "blockType": "response", "@type": "microsoft.graph.list", "truncated": true, "scopes": "sites.read.all service.sharepoint" } -->
148151

149152
```http
@@ -155,23 +158,25 @@ Content-type: application/json
155158
"name": "MicroFeed",
156159
"createdDateTime": "2016-08-30T08:32:00Z",
157160
"lastModifiedDateTime": "2016-08-30T08:32:00Z",
161+
"itemCount": 45,
158162
"list": {
159163
"hidden": false,
160164
"template": "genericList"
161165
}
162166
}
163167
```
164168

165-
With `select` and `expand` statements, you can retrieve list metadata, column definitions, and list items in a single request.
169+
### Example 3: Get list metadata and items with $select and $expand
170+
The following example shows how to use the `$select` and `$expand` OData query parameters to retrieve list metadata, column definitions, and list items in a single request.
166171

167172
#### Request
168-
173+
The following example shows a request.
169174

170175
# [HTTP](#tab/http)
171176
<!-- { "blockType": "request", "name": "get-list-multi-expand" } -->
172177

173178
```msgraph-interactive
174-
GET /sites/{site-id}/lists/{list-id}?select=name,lastModifiedDateTime&expand=columns(select=name,description),items(expand=fields(select=Name,Color,Quantity))
179+
GET /sites/{site-id}/lists/{list-id}?select=name,lastModifiedDateTime,itemCount&expand=columns(select=name,description),items(expand=fields(select=Name,Color,Quantity))
175180
```
176181

177182
# [C#](#tab/csharp)
@@ -205,7 +210,7 @@ GET /sites/{site-id}/lists/{list-id}?select=name,lastModifiedDateTime&expand=col
205210
---
206211

207212
#### Response
208-
213+
The following example shows the response.
209214
<!-- { "blockType": "response", "@type": "microsoft.graph.list", "truncated": true, "scopes": "sites.read.all service.sharepoint" } -->
210215

211216
```http
@@ -254,21 +259,24 @@ Content-type: application/json
254259
"Quantity": 92
255260
}
256261
}
257-
]
262+
],
263+
"itemCount": 45
258264
}
259265
```
260-
#### Request
261266

262-
<!-- { "blockType": "request", "name": "get-list-multi-expand" } -->
267+
### Example 4: Get list metadata and items with multiple $expand parameters
268+
The following example shows how to get metadata and items for a list that contains three columns: *Name*, *Quantity*, and *Category*. [Managed metadata](/sharepoint/managed-metadata) columns like *Category* return values as term ID and term name pair.
269+
270+
#### Request
271+
The following example shows a request.
272+
<!-- { "blockType": "request", "name": "get-list-multi-expand_4" } -->
263273

264-
The following example shows how to get metadata for a list that contains three columns: Name, Quantity, and Category.
265-
[Managed Metadata](/sharepoint/managed-metadata) columns like ```Category``` return values as term ID and term name pair.
266274
```http
267275
GET /sites/{site-id}/lists/{list-id}?select=name,lastModifiedDateTime&expand=columns(select=name,description),items(expand=fields(select=Name,Quantity,Category))
268276
```
269277

270278
#### Response
271-
279+
The following example shows the response.
272280
<!-- { "blockType": "response", "@type": "microsoft.graph.list", "truncated": true, "scopes": "sites.read.all service.sharepoint" } -->
273281

274282
```http

api-reference/beta/api/list-list.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Content-type: application/json
108108
"name": "Documents",
109109
"createdDateTime": "2016-08-30T08:32:00Z",
110110
"lastModifiedDateTime": "2016-08-30T08:32:00Z",
111+
"itemCount": 312,
111112
"list": {
112113
"hidden": false,
113114
"template": "documentLibrary"
@@ -118,6 +119,7 @@ Content-type: application/json
118119
"name": "MicroFeed",
119120
"createdDateTime": "2016-08-30T08:32:00Z",
120121
"lastModifiedDateTime": "2016-08-30T08:32:00Z",
122+
"itemCount": 45,
121123
"list": {
122124
"hidden": false,
123125
"template": "genericList"

api-reference/beta/resources/list.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Represents a list in a [site](site.md). This resource contains the top level pro
5050
| displayName | String | The displayable title of the list. |
5151
| eTag | String | ETag for the item. Inherited from [baseItem](baseitem.md). |
5252
| id | String | The unique identifier of the item. Read-only. Inherited from [baseItem](baseitem.md). |
53-
| itemCount | Int32 | The number of items in the list. Read-only. |
53+
| itemCount | Int32 | The total count of items in the list. Read-only. |
5454
| lastModifiedBy | [identitySet](identityset.md) | Identity of the last modifier of this item. Read-only. Inherited from [baseItem](baseitem.md). |
5555
| lastModifiedDateTime | DateTimeOffset | The date and time when the item was last modified. Read-only. Inherited from [baseItem](baseitem.md). |
5656
| list | [listInfo](listinfo.md) | Contains more details about the list. |
@@ -90,6 +90,7 @@ The following JSON representation shows the resource type.
9090
"displayName": "String",
9191
"eTag": "String",
9292
"id": "String (identifier)",
93+
"itemCount": "Int32",
9394
"lastModifiedBy": { "@odata.type": "microsoft.graph.identitySet" },
9495
"lastModifiedDateTime": "String (timestamp)",
9596
"list": { "@odata.type": "microsoft.graph.listInfo" },

changelog/Microsoft.FileServices.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
{
22
"changelog": [
3+
{
4+
"ChangeList": [
5+
{
6+
"Id": "5d6e9a5b-3c66-40c9-b3dd-a6fa374f1240",
7+
"ApiChange": "Property",
8+
"ChangedApiName": "itemCount",
9+
"ChangeType": "Addition",
10+
"Description": "Added the **itemCount** property to the [list](https://learn.microsoft.com/en-us/graph/api/resources/list?view=graph-rest-beta) resource.",
11+
"Target": "list"
12+
}
13+
],
14+
"Id": "5d6e9a5b-3c66-40c9-b3dd-a6fa374f1240",
15+
"Cloud": "Prod",
16+
"Version": "beta",
17+
"CreatedDateTime": "2026-04-24T23:41:39.1409717Z",
18+
"WorkloadArea": "Files",
19+
"SubArea": ""
20+
},
321
{
422
"ChangeList": [
523
{

concepts/whats-new-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ Added the **deprecationDate** property to the [applicationTemplate](/graph/api/r
7272

7373
### Files
7474

75-
Use the **height** and **width** query parameters on the [driveItem content conversion API](/graph/api/driveitem-get-content-format?view=graph-rest-beta&preserve-view=true) to download a file in another format when `format=jpg`.
75+
- Use the **height** and **width** query parameters on the [driveItem content conversion API](/graph/api/driveitem-get-content-format?view=graph-rest-beta&preserve-view=true) to download a file in another format when `format=jpg`.
76+
- Use the **itemCount** property on the [list](/graph/api/resources/list?view=graph-rest-beta&preserve-view=true) resource to quickly access the total number of items in a SharePoint list without retrieving all items or making additional queries.
7677

7778
### Identity and access | Governance
7879

@@ -242,7 +243,6 @@ Use the [follow user](/graph/api/storyline-follow?view=graph-rest-beta&preserve-
242243
- Use the [list](/graph/api/filestoragecontainertype-list-permissions?view=graph-rest-beta&preserve-view=true), [create](/graph/api/filestoragecontainertype-post-permissions?view=graph-rest-beta&preserve-view=true), [get](/graph/api/filestoragecontainertype-get-permission?view=graph-rest-beta&preserve-view=true), and [delete](/graph/api/filestoragecontainertype-delete-permissions?view=graph-rest-beta&preserve-view=true) APIs to manage user permissions for SharePoint Embedded [file storage container types](/graph/api/resources/filestoragecontainertype?view=graph-rest-beta&preserve-view=true).
243244
- [Archive](/graph/api/filestoragecontainer-archive?view=graph-rest-beta&preserve-view=true) or [unarchive](/graph/api/filestoragecontainer-unarchive?view=graph-rest-beta&preserve-view=true) a SharePoint Embedded storage container.
244245
- Requests made using the [list containers](/graph/api/filestorage-list-containers?view=graph-rest-beta&preserve-view=true) API without a user context (app-only authentication) aren't currently supported for multi-geo tenants.
245-
- Use the **itemCount** property on the [list](/graph/api/resources/list?view=graph-rest-beta&preserve-view=true) resource to quickly access the total number of items in a SharePoint list without retrieving all items or making additional queries.
246246
- Use the **principalId** property on [sharePointGroup](/graph/api/resources/sharepointgroup?view=graph-rest-beta&preserve-view=true) to get the principal ID of the SharePoint group in the tenant.
247247
- Use the **sharePointGroup** property on [sharePointIdentitySet](/graph/api/resources/sharepointidentityset?view=graph-rest-beta&preserve-view=true) to get the SharePoint group associated with a **sharePointIdentitySet** object.
248248

0 commit comments

Comments
 (0)