如何在 prem 实例上使用 REST API 为 TFS 2015 获取服务端点列表?

How to get a list of Service Endpoints using REST API for TFS 2015 on prem instance?

我正在为 TFS 2015 使用基于 REST 的 API 来获取服务端点列表(根据 reference)。但在提取信息时遇到问题。

我们有一个 TFS 2015(版本 14.102.25423.0)的本地实例。下面是 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

谁能告诉我如何解决这个问题?或者让我参考一些额外的文档。

我已经使用 TFS 2015 Update 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

您可以通过Get a team project rest API first and then use the ID of the project to get the service endpoints via the Service EndpointsAPI获取项目ID。所以 URL 应该是这样的:

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