Escolha a permissão ou as permissões marcadas como menos privilegiadas para essa API. Use uma permissão ou permissões privilegiadas mais altas somente se o aplicativo exigir. Para obter detalhes sobre permissões delegadas e de aplicativo, consulte Tipos de permissão. Para saber mais sobre essas permissões, consulte a referência de permissões.
No corpo da solicitação, forneça uma representação JSON de um objeto list .
Resposta
Se for bem-sucedido, esse método retornará um 201 Created código de resposta e um objeto de lista no corpo da resposta.
Exemplos
Solicitação
Veja a seguir um exemplo de como criar uma nova lista genérica.
Observação: Colunas personalizadas são opcionais.
Além de todas as colunas especificadas aqui, novas listas são criadas com colunas definidas no modelo referenciado.
Se a faceta lista ou modelo não for especificada, a lista considera como padrão o modelo genericList, que inclui uma coluna Título.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new List
{
DisplayName = "Books",
Columns = new List<ColumnDefinition>
{
new ColumnDefinition
{
Name = "Author",
Text = new TextColumn
{
},
},
new ColumnDefinition
{
Name = "PageCount",
Number = new NumberColumn
{
},
},
},
List = new ListInfo
{
Template = "genericList",
},
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Sites["{site-id}"].Lists.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewList()
displayName := "Books"
requestBody.SetDisplayName(&displayName)
columnDefinition := graphmodels.NewColumnDefinition()
name := "Author"
columnDefinition.SetName(&name)
text := graphmodels.NewTextColumn()
columnDefinition.SetText(text)
columnDefinition1 := graphmodels.NewColumnDefinition()
name := "PageCount"
columnDefinition1.SetName(&name)
number := graphmodels.NewNumberColumn()
columnDefinition1.SetNumber(number)
columns := []graphmodels.ColumnDefinitionable {
columnDefinition,
columnDefinition1,
}
requestBody.SetColumns(columns)
list := graphmodels.NewListInfo()
template := "genericList"
list.SetTemplate(&template)
requestBody.SetList(list)
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
lists, err := graphClient.Sites().BySiteId("site-id").Lists().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
List list = new List();
list.setDisplayName("Books");
LinkedList<ColumnDefinition> columns = new LinkedList<ColumnDefinition>();
ColumnDefinition columnDefinition = new ColumnDefinition();
columnDefinition.setName("Author");
TextColumn text = new TextColumn();
columnDefinition.setText(text);
columns.add(columnDefinition);
ColumnDefinition columnDefinition1 = new ColumnDefinition();
columnDefinition1.setName("PageCount");
NumberColumn number = new NumberColumn();
columnDefinition1.setNumber(number);
columns.add(columnDefinition1);
list.setColumns(columns);
ListInfo list1 = new ListInfo();
list1.setTemplate("genericList");
list.setList(list1);
List result = graphClient.sites().bySiteId("{site-id}").lists().post(list);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\List;
use Microsoft\Graph\Generated\Models\ColumnDefinition;
use Microsoft\Graph\Generated\Models\TextColumn;
use Microsoft\Graph\Generated\Models\NumberColumn;
use Microsoft\Graph\Generated\Models\ListInfo;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new EscapedList();
$requestBody->setDisplayName('Books');
$columnsColumnDefinition1 = new ColumnDefinition();
$columnsColumnDefinition1->setName('Author');
$columnsColumnDefinition1Text = new TextColumn();
$columnsColumnDefinition1->setText($columnsColumnDefinition1Text);
$columnsArray []= $columnsColumnDefinition1;
$columnsColumnDefinition2 = new ColumnDefinition();
$columnsColumnDefinition2->setName('PageCount');
$columnsColumnDefinition2Number = new NumberColumn();
$columnsColumnDefinition2->setNumber($columnsColumnDefinition2Number);
$columnsArray []= $columnsColumnDefinition2;
$requestBody->setColumns($columnsArray);
$list = new ListInfo();
$list->setTemplate('genericList');
$requestBody->setEscapedList($list);
$result = $graphServiceClient->sites()->bySiteId('site-id')->lists()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.list import List
from msgraph.generated.models.column_definition import ColumnDefinition
from msgraph.generated.models.text_column import TextColumn
from msgraph.generated.models.number_column import NumberColumn
from msgraph.generated.models.list_info import ListInfo
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = List_(
display_name = "Books",
columns = [
ColumnDefinition(
name = "Author",
text = TextColumn(
),
),
ColumnDefinition(
name = "PageCount",
number = NumberColumn(
),
),
],
list = ListInfo(
template = "genericList",
),
)
result = await graph_client.sites.by_site_id('site-id').lists.post(request_body)