【问题标题】:TFS Rest API : Operation Timed outTFS Rest API:操作超时
【发布时间】:2017-05-10 15:52:17
【问题描述】:

我正在尝试使用 TFS REST API 获取项目集合,如下所示,

curl -u "username@domain.com"[:"personal access token"] 
https://tfstracker.visualstudio.com:8080/DefaultCollection/_apis/projects?
api-version=2.0

失败并出现以下错误:

curl: (7) Failed to connect to tfstracker.visualstudio.com port 8080: Operation timed out.

我使用的是在线 TFS,即网页版。

更新1:

尝试按照建议调用 API,但出现以下错误:

curl -u <username>[:<AccessToken>] https://tfstracker.visualstudio.com/DefaultCollection/_apis/projects?api-version=1.0

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://app.vssps.visualstudio.com/_signin?realm=tfstracker.visualstudio.com&amp;reply_to=https%3A%2F%2Ftfstracker.visualstudio.com%2FDefaultCollection%2F_apis%2Fprojects%3Fapi-version%3D1.0&amp;redirect=1&amp;context=eyJodCI6MiwiaGlkIjoiOGE4OWMxODUtNDRjNC00YWRkLWI3ZjgtZWIyNDhiZTIwMjAyIiwicXMiOnt9LCJyciI6IiIsInZoIjoiIiwiY3YiOiIiLCJjcyI6IiJ90#ctx=eyJTaWduSW5Db29raWVEb21haW5zIjpbImh0dHBzOi8vbG9naW4ubWljcm9zb2Z0b25saW5lLmNvbSIsImh0dHBzOi8vbG9naW4ubWljcm9zb2Z0b25saW5lLmNvbSJdfQ2">here</a>.</h2>
</body></html>

更新2: 这是有效的命令

curl -u "username@domain.com:accesstoken" https://tfstracker.visualstudio.com/DefaultCollection/_apis/projects?api-version=2.0

【问题讨论】:

  • 您使用的是本地 TFS 还是 VSTS?您想获取团队项目还是项目集合?
  • 我正在使用 TFS 在线、团队项目或项目集合 - 任何事情都可以。在 POC 阶段。

标签: tfs azure-devops


【解决方案1】:

如果你使用 VSTS,URL 应该是https://tfstracker.visualstudio.com/DefaultCollection,没有端口。

如果您使用本地 TFS,则 URL 应类似于 http://tfsserver:8080/tfs/DefaultCollection

根据您的 API,您似乎想要获取团队项目列表,而不是项目集合。 get a list of team projects的API如下:

Get http(s)://{instance}/DefaultCollection/_apis/projects?api-version=1.0

如果你想get a project collection,API 应该是这样的:

GET http(s)://{instance}/DefaultCollection/_apis/projectCollections/{collection}?api-version=1.0-preview.2

实例:VS Team Services 帐户 ({account}.visualstudio.com) 或 TFS 服务器({server:port})。


更新:

我已经测试了以下命令,它可以工作。更正您的格式并确保您已按照 this article 创建个人访问令牌。

curl -u "username@domain.com:个人访问令牌" https://tfstracker.visualstudio.com/DefaultCollection/_apis/projects?api-version=2.0

【讨论】:

猜你喜欢
  • 2015-08-10
  • 1970-01-01
  • 2013-04-02
  • 1970-01-01
  • 2020-04-28
  • 2019-07-05
  • 2017-06-24
  • 1970-01-01
  • 2012-08-30
相关资源
最近更新 更多