1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SharePoint の listItem を driveItem として操作する

Last updated at Posted at 2025-04-02

Graph api (OneDrive & SharePoint Online かも?) から操作するときに困ったのでメモ。

ブラウザから作ったものが driveItem だと思っていたら listItem だった。

要点

ドキュメントライブラリの listItem は site/{site-id}/list/{list-id}/drive で指定すれば driveItem として操作できる。

sharepoint フォルダについて

OneDrive & SharePoint Online

API が提供されている。大体 Microsoft Graph API と同じ。

アプリからの操作なので、Entra 管理画面でアプリを登録して、権限設定を実施しておく。

操作概要

各フォルダや各ファイルにIDが振られているので、それを取ってきておいて、ID指定で操作する。

site API でサイトのIDをとって、site/{site-id}/lists でリストのIDをとって、site/{site-id}/drive でドライブのIDをとって、
取得したIDを使って適宜操作していく。

listItem と driveItem

ブラウザ操作でドキュメントライブラリを作ると、listItem になった。

ドキュメントライブラリならlistItem は driveItem として扱われるみたいな記載はある。

困ったこと

listItem としての操作でフォルダを作ろうとすると、files and folders should only be added to a documentlibrary via the onedrive api エラーが出る。

listItem の操作は OneDrive API ではないよという記載なので、listItem が SharePoint 管理で driveItem が OneDrive 管理っぽい。

解決

site/{site-id}/list/{list-id}/drive で driveItem として操作できる。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?