API からアクセス可能なレポートを取得して実行するには、以下のメソッドを使用します。
API テンプレート セクションのレポートは、get_reports および run_report エンドポイントを使用して参照および実行できます。
レポートは実行直後には利用できない場合があります。特に TestRail Server をご利用の場合、レポートが利用可能になるまでにかかる時間は異なる場合があります。
get_reports
TestRail 5.7 以降が必要です。
プロジェクトの API から利用可能なレポートのリストを返します。
GET index.php?/api/v2/get_reports/{project_id}
パラメーター
| 名前 | タイプ | 必須 | 説明 |
|---|---|---|---|
| project_id | integer | true | API から利用可能なレポートのリストが必要なプロジェクトのID |
レスポンスの内容
典型的なレスポンスについては、下記を参照してください。
[
{
"id": 1,
"name": "Activity Summary (Cases) %date%",
"description": null,
"notify_user": true,
"notify_link": false,
"notify_link_recipients": null,
"notify_attachment": false,
"notify_attachment_recipients": "person1@example.com\r\nperson2@example.com",
"notify_attachment_html_format": false,
"notify_attachment_pdf_format": false,
"cases_groupby": "day",
"changes_daterange": "5",
"changes_daterange_from": null,
"changes_daterange_to": null,
"suites_include": "1",
"suites_ids": null,
"sections_include": "1",
"sections_ids": null,
"cases_columns": {
"cases:id": 75,
"cases:title": 0,
"cases:created_by": 125,
"cases:updated_by": 125
},
"cases_filters": null,
"cases_limit": 1000,
"content_hide_links": false,
"cases_include_new": true,
"cases_include_updated": true
}
]
レスポンスには次のシステム項目が常に含まれています。
| 名前 | タイプ | 説明 |
|---|---|---|
| id | integer | レポートの一意の ID |
| name | string | レポートの名前 |
| description | string | レポートの説明 |
| notify_user | boolean | レポートの作成後に作成者に通知するかどうかを指定します |
| notify_link | boolean | レポートへのリンクを記載した電子メールを送信するかどうかを指定します |
| notify_link_recipients | string | レポートの送信先となるユーザーのリスト |
| notify_attachment | boolean | レポートを電子メールの添付ファイルとして送信するかどうかを指定します |
| notify_attachment_html_format | boolean | notify_ attachment が true の場合、レポートを HTML 形式で添付するかどうかを指定します |
| notify_attachment_pdf_format | boolean | notify_ attachment が true の場合、レポートを PDF 形式で添付するかどうかを指定します |
レスポンス コード
| ステータス コード | 説明 |
|---|---|
| 200 | 成功。レポートはレスポンスの一部として返されます |
| 400 | 無効または不明なプロジェクト |
| 403 | プロジェクトにアクセスできない |
| 429 | TestRail Cloud のみ – リクエストが多すぎます |
run_report
TestRail 5.7 以降が必要です。
report_id パラメーターで指定されたレポートを実行し、HTML および PDF 形式のレポートにアクセスするための URL を返します。
GET index.php?/api/v2/run_report/{report_template_id}
レスポンスの内容
{
"report_url": "https://docs.testrail.com/index.php?/reports/view/383",
"report_html": "https://docs.testrail.com/index.php?/reports/get_html/383",
"report_pdf": "https://docs.testrail.com/index.php?/reports/get_pdf/383"
}
レスポンス コード
| ステータス コード | 説明 |
|---|---|
| 200 | 成功。レポートはレスポンスの一部として返されます |
| 400 | 無効なレポート テンプレート ID です |
| 403 | プロジェクトにアクセスできない |
| 429 | TestRail Cloud のみ – リクエストが多すぎます |

