LoginSignup
8
3

More than 3 years have passed since last update.

Microsoft Graph APIでSharepointのサイトIDを調べる方法

Posted at

Graph APIでSharepointのサイトIDを取得する方法がわからずハマったので備忘録として残しておきます。

Sharepoint サイトIDとは

GraphAPIでSharepointのサイト内の情報を見る際に必要なIDです。

contoso.sharepoint.com,2C712604-1370-44E7-A1F5-426573FDA80A,2D2244C3-251A-49EA-93A8-39E1C3A060FE

サイトは、次の値の複合 ID である一意の識別子によってアドレス指定されます。

  • サイト コレクションのホスト名 (contoso.sharepoint.com)
  • サイト コレクションの一意 ID (GUID)
  • サイトの一意 ID (GUID)

参考:https://docs.microsoft.com/ja-jp/graph/api/site-get?view=graph-rest-1.0&tabs=http

サイトIDの調べかた

APIをたたくだけですが、GraphエクスプローラーというGraphAPI専用のAPIクライアントがあるので、これを使います

【Graphエクスプローラー】
https://developer.microsoft.com/ja-jp/graph/graph-explorer

サンプルも結構あるので、リファレンスがわからん!という場合はサンプルから探した方が早いかもしれません

ルートからの相対パスで検索

https://graph.microsoft.com/v1.0/sites/root:/{path}

→https://{tenant}.sharepoint.comにアクセスしたときのサブサイトのみが取得できる?

キーワードで検索

ルートからの相対パスで検索にてヒットしない場合はキーワードで検索するのが早いです。

https://graph.microsoft.com/v1.0/sites?search=contoso

最後に

キーワードでの検索を知るまでサイトが全然出てこなくてかなり無駄な時間を過ごしてしまいました。
Microsoftのリファレンスの読みづらさはどうにかならないもんか。。。

8
3
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
8
3