2016-11-09 24 views
0

我使用REST基於API的TFS 2015年獲得服務端點的列表(按照reference)。但是在提取信息時面臨一個問題。如何在預先實例上使用TFS 2015的REST API獲取服務端點列表?

我們有一個在2015年TFS(版本14.102.25423.0)的PREM實例。以下是我試圖獲取服務端點列表的URL。

https://tfs-on-prem-instance/DefaultCollection/product-name/_apis/distributedtask/serviceendpoints?api-version=3.0-preview.1

錯誤:

在瀏覽器

{"count":1,"value":{"Message":"An error has occurred."}} 

在PowerShell中

Invoke-RestMethod : {"count":1,"value":{"Message":"An error has occurred."}} At D:\DevOps\TFS\TFSServiceModule.psm1:75 char:23 + ... $result = Invoke-RestMethod -Method Get -Uri $uri -Credential $Cred ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpW ebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell .Commands.InvokeRestMethodCommand

任何人都可以讓我知道我該如何解決這個問題?或者讓我介紹一些額外的文檔。

+0

您是否有權訪問服務器以檢查Windows事件日誌?另外,你有什麼確切的前提版本? – DaveShaw

+0

我沒有訪問服務器的權限。但我能叫般的服務端點類型其他任何可用的API,獲取/創建版本定義等 –

+0

版本14.102.25423.0 –

回答

1

您可以通過Get a team project休息API獲得該項目的ID,然後再使用該項目的ID通過獲取服務端點Service Endpoints API。因此,URL應該如下所示:

http://tfsinstance/CollectionName/**PROJECTID**/_apis/distributedtask/serviceendpoints?api-version=3.0-preview.1 
+0

謝謝。這對我有效。 –

+0

我這裏使用的上述[端點信息API](https://www.visualstudio.com/en-us/docs/integrate/extensions/reference/client/api/tfs/distributedtask/taskagentrestclient/taskagenthttpclient2_1)的方法中,但我收到錯誤消息「TF400813:資源不可用於匿名訪問,需要客戶端身份驗證。」當使用getServiceEndpointDetails()時,響應狀態爲401 – sify

+0

@sify您在哪裏使用此代碼? –

1

我和TFS 2015更新3(14.102.25423.0)進行測試,但是當遇到下面的API也得到了錯誤:

Get http://tfsserver:8080/tfs/CollectionName/TeamProjectName/_apis/distributedtask/serviceendpoints?api-version=3.0-preview.1 

此API適用於VSTS罰款和TFS 15 RC 2,但沒有按在TFS 2015.3上工作。我已經提交了在下面的網站上的反饋,你可以投票吧:

https://connect.microsoft.com/VisualStudio/feedback/details/3111161

+0

有任何解決方法存在檢索服務端點的名單? –

+0

目前,除檢查Web訪問UI外,沒有任何解決方法可檢索服務端點列表。讓我們跟蹤反饋,看看他們是否可以幫助我們解決問題或提供解決方法。 –

相關問題