2016-07-22 3 views
0

私は作業項目(バグ、タスク)の詳細を取得するために、TFS REST APIに取り組んでいます。 私はそれは私がすべてのバグの詳細情報を取得できませんでした次の出力REST APIを使用してTFS(Team Foundation Server)の作業項目(バグ、タスク)の詳細を取得する方法は?

"id": "e7731d7b-10d2-441f-899f-b081e4008b21", 
    "name": "My Bugs", 
    "path": "Shared Queries/My Bugs", 
    "createdBy": 
    { 
     "id": "7bb24a89-a490-4ffa-9047-252e4a2b274b", 
     "displayName": "kalaisankaran B " 
    }, 
    "createdDate": "2016-07-15T05:30:18.34Z", 
    "lastModifiedBy": 
    { 
     "id": "7bb24a89-a490-4ffa-9047-252e4a2b274b", 
     "displayName": "kalaisankaran B " 
    }, 
    "lastModifiedDate": "2016-07-15T05:30:18.34Z", 
    "isPublic": true, 

を示しGETメソッド、

GET https://shankarsam.visualstudio.com/DefaultCollection/New-1/_apis/wit/queries/Shared%20Queries/My%20Bugs?$depth=1&api-version=2.2 

を使用していました。 UIの場合、共有クエリ - >マイバグ - >バグに移動しました。添付のスクリーンショットをご覧ください。 enter image description here

+0

すべてのフィールドはデフォルトで取得されますが、詳細は不足していますか? –

答えて

0

私は解決策を得ました。プロジェクトに関連付けられているすべてのバグやタスクを表示する必要がある場合。次の残りのAPI呼び出しを使用します。

POST https://<Account Name>.visualstudio.com/DefaultCollection/<Project Name>/_apis/wit/wiql?api-version=1.0 
    Ex : 
    POST https://shankarsam.visualstudio.com/DefaultCollection/New-1/_apis/wit/wiql?api-version=1.0 

ヘッダー:

Content-Type application/json 

リクエストボディ例:

{ 
    "query": "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.WorkItemType] = 'Bug'" 
    } 

タスク項目を表示する必要があることを意味し、この[System.WorkItemType] = 'Task'

表示バグやタスクに関連する作業項目を試してみてください、レポの試してみてください:

GET https://<Account Name>.visualstudio.com/DefaultCollection/_apis/wit/workitems?id=<Issue ID>&$expand=all&api-version=1.0 
    Ex: 
    GET https://shankarsam.visualstudio.com/DefaultCollection/_apis/wit/workitems?id=23&$expand=all&api-version=1.0 
3

これは、REST API Documentationを見るのが最も良い場所です。この正確なシナリオには、いくつかの有用な例が含まれています。

クエリ階層を取得したことがわかりました。クエリ階層を取得してから、クエリを実行してから作業項目を取得できます。

上記の呼び出しから、私は "My Bugs"クエリを例として使用します。

クエリ結果を返します
GET https://shankarsam.visualstudio.com/DefaultCollection/New-1/_apis/wit/wiql/7731d7b-10d2-441f-899f-b081e4008b21 

{ 
    "queryType": "flat", 
    "workItems": [ 
    { 
     "id": 300, 
     "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/300" 
    } 
    ] 
} 

ことから、作業項目を取得するために、結果にidプロパティを使用することができます。

作業を返します
GET https://shankarsam.visualstudio.com/DefaultCollection/New-1/_apis/wit/workItems/1 

項目。

関連する問題