Article
07/06/2023
14 contributors
Feedback
In this article
Namespace: microsoft.graph
Returns the metadata for a list .
This API is supported in the following national cloud deployments .
Global service
US Government L4
US Government L5 (DOD)
China operated by 21Vianet
✅
✅
✅
✅
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Sites.Read.All, Sites.ReadWrite.All
Delegated (personal Microsoft account)
Not supported.
Application
Sites.Read.All, Sites.ReadWrite.All
HTTP request
GET /sites/{site-id}/lists/{list-id}
GET /sites/{site-id}/lists/{list-title}
GET /sites/{site-id}/lists/{list-id}?expand=columns,items(expand=fields)
Request body
Do not supply a request body with this method.
Example
Request
GET /sites/{site-id}/lists/{list-id}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var result = await graphClient.Sites["{site-id}"].Lists["{list-id}"].GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
lists, err := graphClient.Sites().BySiteId("site-id").Lists().ByListId("list-id").Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
List list = graphClient.sites("{site-id}").lists("{list-id}")
.buildRequest()
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
let list = await client.api('/sites/{site-id}/lists/{list-id}')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->sites()->bySiteId('site-id')->lists()->byListId('list-id')->get()->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(request_adapter)
result = await graph_client.sites.by_site_id('site-id').lists.by_list_id('list-id').get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "1234-112-112-4",
"name": "MicroFeed",
"createdDateTime": "2016-08-30T08:32:00Z",
"lastModifiedDateTime": "2016-08-30T08:32:00Z",
"list": {
"hidden": false,
"template": "genericList"
}
}
With select
and expand
statements, you can retrieve list metadata, column definitions, and list items in a single request.
Request
The following example shows how to get a list from a SharePoint Online list title.
GET /sites/{site-id}/lists/{list-title}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var result = await graphClient.Sites["{site-id}"].Lists["{list-id}"].GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
lists, err := graphClient.Sites().BySiteId("site-id").Lists().ByListId("list-id").Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
List list = graphClient.sites("{site-id}").lists("{list-title}")
.buildRequest()
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
let list = await client.api('/sites/{site-id}/lists/{list-title}')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->sites()->bySiteId('site-id')->lists()->byListId('list-id')->get()->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(request_adapter)
result = await graph_client.sites.by_site_id('site-id').lists.by_list_id('list-id').get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "1234-112-112-4",
"name": "MicroFeed",
"createdDateTime": "2016-08-30T08:32:00Z",
"lastModifiedDateTime": "2016-08-30T08:32:00Z",
"list": {
"hidden": false,
"template": "genericList"
}
}
With select
and expand
statements, you can retrieve list metadata, column definitions, and list items in a single request.
Request
GET /sites/{site-id}/lists/{list-id}?select=id,name,lastModifiedDateTime&expand=columns(select=name,description),items(expand=fields(select=Name,Color,Quantity))
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var result = await graphClient.Sites["{site-id}"].Lists["{list-id}"].GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Select = new string []{ "id","name","lastModifiedDateTime" };
requestConfiguration.QueryParameters.Expand = new string []{ "columns(select=name,description)","items",")" };
});
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphsites "github.com/microsoftgraph/msgraph-sdk-go/sites"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestParameters := &graphsites.SiteItemListItemRequestBuilderGetQueryParameters{
Select: [] string {"id","name","lastModifiedDateTime"},
Expand: [] string {"columns(select=name,description)","items",")"},
}
configuration := &graphsites.SiteItemListItemRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
lists, err := graphClient.Sites().BySiteId("site-id").Lists().ByListId("list-id").Get(context.Background(), configuration)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new QueryOption("select", "id,name,lastModifiedDateTime"));
requestOptions.add(new QueryOption("expand", "columns(select=name,description),items(expand=fields(select=Name,Color,Quantity))"));
List list = graphClient.sites("{site-id}").lists("{list-id}")
.buildRequest( requestOptions )
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
let list = await client.api('/sites/{site-id}/lists/{list-id}?select=id,name,lastModifiedDateTime&expand=columns(select=name,description),items(expand=fields(select=Name,Color,Quantity))')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new ListItemRequestBuilderGetRequestConfiguration();
$queryParameters = ListItemRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->select = ["id","name","lastModifiedDateTime"];
$queryParameters->expand = ["columns(select=name,description)","items",")"];
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->sites()->bySiteId('site-id')->lists()->byListId('list-id')->get($requestConfiguration)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Import-Module Microsoft.Graph.Sites
Get-MgSiteList -SiteId $siteId -ListId $listId -Property "id,name,lastModifiedDateTime" -ExpandProperty "columns(select=name,description),items)"
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(request_adapter)
query_params = ListRequestBuilder.ListRequestBuilderGetQueryParameters(
select = ["id","name","lastModifiedDateTime"],
expand = ["columns(select=name,description)","items",")"],
)
request_configuration = ListRequestBuilder.ListRequestBuilderGetRequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.sites.by_site_id('site-id').lists.by_list_id('list-id').get(request_configuration = request_configuration)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "1234-112-112-4",
"name": "Inventory",
"lastModifiedDateTime": "2016-08-30T08:32:00Z",
"columns": [
{
"name": "Name",
"description": "Customer-facing name of the SKU"
},
{
"name": "Color",
"description": "Color of the item in stock"
},
{
"name": "Quantity",
"description": "Number of items in stock"
}
],
"items": [
{
"id": "2",
"fields": {
"Name": "Gadget",
"Color": "Red",
"Quantity": 503
}
},
{
"id": "4",
"fields": {
"Name": "Widget",
"Color": "Blue",
"Quantity": 2357
}
},
{
"id": "7",
"fields": {
"Name": "Gizmo",
"Color": "Green",
"Quantity": 92
}
}
]
}