LoginSignup
5
7

Microsoft Forms API 現時点でのまとめ

Last updated at Posted at 2021-12-29

背景

Power BI 用の Custom Connector を作ろうと改めて調べてみたら、二種類の API path 構成が確認されたので、まとめておく。

API 一覧

現状二種類混在しているが、light を付けるのが古い API かな?
もう一つの odata 系と書いた方には Forms Pro 用のデータが含まれてそうでもあるし。

公式ドキュメントがないので、light の有無のどちらが今後の趨勢かは不明

どちらも、endpoint は同一: https://forms.office.com/formapi

metadata

以下で metadata 取得可能

light 系

概要 api 補足
一覧取得 api/light/forms
テナント/ユーザー指定 api/{tenantID}/users/{userID}/light/forms テナントとユーザーIDを個別には出来なさそう
formId で指定 api/light/forms({form ID})
指定した回答 api/light/forms({form ID})/responses

odata 系 おそらくこちらで公式公開されていくのでは?と。

概要 api 補足
一覧取得 api/forms
formId で指定 api/forms/{form ID}
指定した質問 api/forms/{form ID}/questions
指定した回答 api/forms/{form ID}/responses
自分とシェアしてる一覧 api/sharedWithMeForms
テナント/ユーザー指定 api/{tenantID}/users/{userID}/forms テナント省略は不可。/forms/以降はユーザーと共通
グループ一覧 api/{tenantID}/groups/ テナント省略は不可
テナント&グループ指定 api/{tenantID}/groups/{groupID}/forms テナント省略は不可。/forms/以降はユーザーと共通

取得結果比較

大まかな差としては

  • path
  • odata 系 での Encode
  • light 系には、questions API がない
  • 取得結果に若干の差異あり

formId で指定

image.png

指定した回答

image.png

指定した質問

odata 系にしか無し
image.png

認証

利用するためには認証が必要です。
ブラウザでなら簡単に試せます。

ブラウザで

以下にアクセスする。timeout は不明

コードで

以下でコード的な取得方法の説明有り

2021-12-29_16h09_42.png

Power Automate で

SharePoint の Http コネクタで出来ちゃいます。send-an-http-request-to-sharepoint

詳細は以下で

Power Query カスタムコネクタで

詳細は以下お勧め。

カスタムコネクタでの認証設定例
// Data Source Kind description <https://github.com/microsoft/DataConnectors/blob/master/docs/m-extensions.md>
PQExtensionFormsAPI = [
    Authentication = [
        Aad = [
            AuthorizationUri = "https://login.microsoftonline.com/common/oauth2/authorize",
            Resource = "https://forms.office.com" // Azure AD resource value for your service - Guid or URL
        ]
    ],
    Label = Extension.LoadString("Forms API で Response 取得") // (optional Friendly display name for this extension in credential dialogs.         
    // , TestConnection    Gateway 経由でデータ更新する場合にはサポート必要
];

あとがき

次回はようやく、カスタムコネクタ公開へ・・?

keyword

How to use Microsoft Forms API

5
7
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
5
7