rksoftware

Visual Studio とか C# とかが好きです

SharePoint REST API でリストを作成する

SharePont Online の REST API でリストを作成してみます。

公式はこんな感じです。

learn.microsoft.com

次のような JSON を POST することになっています。

{
  "__metadata": {
    "type": "SP.List"
  },
  "AllowContentTypes": true,
  "BaseTemplate": 100,
 "ContentTypesEnabled": true,
 "Description": "My list description",
 "Title": "Test"
}

しかし、残念ながら動きませんでした。

■ 動いたコード

POST

https://{サイトの URL}/_api/web/lists
{
  "AllowContentTypes": true,
  "BaseTemplate": 100,
 "ContentTypesEnabled": true,
 "Description": "My list description",
 "Title": "Test"
}

"__metadata" プロパティを消すと動作しました。

Power Automate ではこんな感じです。