フィールド構文
In the YouTrack REST API, when you send an HTTP request to a resource, the server returns only the database ID and $type of the resource entity by default. To include other attributes in the response, specify them explicitly in the fields parameter of the request.
利用可能なフィールド名を見つける方法
fields パラメーターで使用できるフィールド名は、要求したリソースによって返されるエンティティの属性と一致します。
特定のリクエストで使用可能なフィールド名を確認するには、対応するエンティティのリファレンスページを開きます。例: リクエストが Issue を返す場合は、課題エンティティのリファレンスを確認してください。User を返す場合は、ユーザーエンティティのリファレンスを確認してください。
利用可能なエンティティ参照ページを閲覧するには、API リファレンスのエンティティセクションを開いてください。
Field Expressions
Use a comma-separated list of attribute names as the value of fields . To request nested data, follow the structure of the JSON object in the response. For nested entities and collections, put the attributes you need in parentheses after the entity or collection name. The following expressions apply to an Issue entity.
選択範囲 | Example expression | Returned data |
|---|---|---|
Top-level attributes |
| Issue ID and summary. |
Nested entity attributes |
| Name of the issue's project. |
Nested collection attributes |
| ID and name of each issue custom field. |
Combined selections |
| Issue ID, summary, and project name. |
For example, pass the combined expression as the fields query parameter:
Start with a small set of top-level fields, inspect the response, and then extend the expression with nested attributes as needed.
サンプル
The following examples start with a request without fields , then show how to select top-level and nested attributes. They also cover issue custom fields and work item data.
フィールドなしのリクエストパラメーター
This request omits the fields parameter.
リクエスト
レスポンスボディ
The response contains the user's database id and $type :
Fields パラメーターを使用したリクエスト
This request uses fields to select the current user's id、login、name、email attributes.
リクエスト
レスポンスボディ
The response contains the requested attributes and $type :
ネストされたフィールドを含むリクエスト
ネストされたオブジェクトを持つエンティティの場合、子オブジェクトやコレクションからも属性を要求できます。次の例では、fields パラメーターによって、課題 ID と概要、プロジェクト名、カスタムフィールドの選択データが要求されます。
リクエスト
レスポンスボディ
The response contains the requested top-level and nested attributes, along with entity $type values:
特定の課題に関するカスタムフィールドを選択する
Priority や State などの課題カスタムフィールドは、Issue.customFields コレクションに属します。/api/issues を要求する際には、fields に customFields(...) を含めることで、各課題カスタムフィールドに対して返される属性を指定できます。
個別のクエリパラメーター customFields を使用して、課題のカスタムフィールドを名前で選択します。含めたいカスタムフィールドごとに、このパラメーターを繰り返してください。
返される各課題には、要求された Priority および State カスタムフィールドが含まれています。customFields パラメーターを省略した場合、YouTrack は fields で要求されたすべての利用可能な課題カスタムフィールドを返します。
作業項目属性のリクエスト
/api/workItems リソースは IssueWorkItem エンティティを返します。id、text、duration などの作業項目属性を要求するには、fields を使用してください。
設定可能な作業項目属性は、作業項目の attributes コレクションに属します。これらの属性の ID と値を取得するには、fields に attributes(id,value(name)) を含めます。
作業項目の回答におけるリクエスト課題のカスタムフィールド
作業項目の関連課題のデータを含めるには、fields 内でネストされた issue(...) 式を使用します。次のリクエストでは、各作業項目の応答に、関連課題のカスタムフィールド Priority と State が含まれます。
ここで、customFields は関連する課題の issue.customFields コレクション内のエントリを選択します。作業項目の attributes コレクション内のエントリは選択されません。関連する課題のプロパティで作業項目リストをフィルタリングするには、query を使用します。