Skip to main content

spo listitem add

Creates a list item in the specified list

Usage

m365 spo listitem add [options]

Options

-u, --webUrl <webUrl>

URL of the site where the item should be added

-l, --listId [listId]

ID of the list where the item should be added. Specify either listTitle, listId or listUrl

-t, --listTitle [listTitle]

Title of the list where the item should be added. Specify either listTitle, listId or listUrl

--listUrl [listUrl]

Server- or site-relative URL of the list. Specify either listTitle, listId or listUrl

-c, --contentType [contentType]

The name or the ID of the content type to associate with the new item

--folder [folder]

The list-relative URL of the folder where the item should be created

-h, --help [help]

Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is options.

--query [query]

JMESPath query string. See http://jmespath.org/ for more information and examples.

-o, --output [output]

Output type. json, text, csv, md, none. Default json.

--verbose

Runs command with verbose logging.

--debug

Runs command with debug logging.

Remarks

When using DateTime fields

When creating a list item with a DateTime field, use the timezone and the format that the site expects, based on its regional settings. Alternatively, a format which works on all regions is the following: yyyy-MM-dd HH:mm:ss. However, you should use the local timezone in all situations. UTC date/time or ISO 8601 formatted date/time is not supported.

Examples

Add an item with Title Demo Item and content type name Item to list with title Demo List in site https://contoso.sharepoint.com/sites/project-x

m365 spo listitem add --contentType Item --listTitle "Demo List" --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo Item"

Add an item with Title Demo Multi Managed Metadata Field and a single-select metadata field named SingleMetadataField to list with title Demo List in site https://contoso.sharepoint.com/sites/project-x

m365 spo listitem add --listTitle "Demo List" --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo Single Managed Metadata Field" --SingleMetadataField "TermLabel1|fa2f6bfd-1fad-4d18-9c89-289fe6941377;"

Add an item with Title Demo Multi Managed Metadata Field and a multi-select metadata field named MultiMetadataField to list with title Demo List in site https://contoso.sharepoint.com/sites/project-x

m365 spo listitem add --listTitle "Demo List" --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo Multi Managed Metadata Field" --MultiMetadataField "TermLabel1|cf8c72a1-0207-40ee-aebd-fca67d20bc8a;TermLabel2|e5cc320f-8b65-4882-afd5-f24d88d52b75;"

Add an item with Title Demo Single Person Field and a single-select people field named SinglePeopleField to list with title Demo List in site https://contoso.sharepoint.com/sites/project-x

m365 spo listitem add --listTitle "Demo List" --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo Single Person Field" --SinglePeopleField "[{'Key':'i:0#.f|membership|markh@conotoso.com'}]"

Add an item with Title Demo Multi Person Field and a multi-select people field named MultiPeopleField to list with title Demo List in site https://contoso.sharepoint.com/sites/project-x

m365 spo listitem add --listTitle "Demo List" --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo Multi Person Field" --MultiPeopleField "[{'Key':'i:0#.f|membership|markh@conotoso.com'},{'Key':'i:0#.f|membership|john.doe@conotoso.com'}]"

Add an item with Title Demo Hyperlink Field and a hyperlink field named CustomHyperlink to list with title Demo List in site https://contoso.sharepoint.com/sites/project-x

m365 spo listitem add --listTitle "Demo List" --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo Hyperlink Field" --CustomHyperlink "https://www.bing.com, Bing"

Add an item with a specific title to a list retrieved by server-relative URL in a specific site

m365 spo listitem add --contentType Item --listUrl /sites/project-x/Documents --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo Item"

Add an item with a specific Title and multi-choice value

m365 spo listitem add --listTitle "Demo List" --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo multi-choice Field" --MultiChoiceField "Choice 1;#Choice 2;#Choice 3"

Add an item with a specific Title and DateTime value

m365 spo listitem add --listTitle "Demo List" --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo DateTime Field" --SomeDateTimeField "2023-01-16 15:30:00"

Response

{
"FileSystemObjectType": 0,
"Id": 234,
"ServerRedirectedEmbedUri": null,
"ServerRedirectedEmbedUrl": "",
"ContentTypeId": "0x01003CDBEB7138618C47A98D56499135D6EE0004C0F5794DEBCC4BAC981AC4AE1BD803",
"Title": "Test",
"Modified": "2022-11-16T20:55:45Z",
"Created": "2022-11-16T20:55:45Z",
"AuthorId": 10,
"EditorId": 10,
"OData__UIVersionString": "1.0",
"Attachments": false,
"GUID": "352e3855-56fa-4b68-b6be-4644d6adf204",
"ComplianceAssetId": null,
"OData__vti_ItemDeclaredRecord": null,
}
CTRL + M