Visual Studio 团队服务 REST API with curl
Visual Studio Team Services REST API with curl
我可以使用 Google 的 DHC 扩展或代码访问团队服务 API,但无法使用 curl 实现相同的目的。
到目前为止我已经尝试过:
curl -H "Authorization: Bearer MY_ACCESS_TOKEN" https://MYINSTANCE.VisualStudio.com/DefaultCollection/_apis/projects?api-version=2.0
我一直在得到 "Object moved to ...." 结果。
我该如何解决这个问题?
我之前遇到过这个问题,通过将“Bearer”更改为“Basic”来解决这个问题。
curl -H "Authorization: Basic <TOKEN>" https://xxxxxx.VisualStudio.com/DefaultCollection/_apis/projects?api-version=2.0
更新:
目前,VSO Rest API 仅支持使用 OAuth 2.0 的基本身份验证和授权访问。您可以使用 Basic Auth 或使用 curl 从 VSO 获取 OAuth2.0 访问令牌。详见此link:Authorize access to REST APIs with OAuth 2.0。
我刚刚尝试使用个人访问令牌进行 DHC,但收到以下消息:"We are sorry, but Chrome API does not allow to get a response body for redirect." 因此您可能需要清除浏览器 cookie 和缓存,然后尝试查看承载是否可以与 VSO Rest 一起使用 API 在 DHC 中。
按照这里的精细手册:
https://docs.microsoft.com/en-us/rest/api/vsts/?view=vsts-rest-4.1
您可以按如下方式格式化您的 curl 请求(以下示例用于检索您的 VSTS 构建):
curl -u username:PATtoekn -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET https://your-account.visualstudio.com/your-project/_apis/build/builds?api-version=4.1 -k
祝你好运!
我可以使用 Google 的 DHC 扩展或代码访问团队服务 API,但无法使用 curl 实现相同的目的。
到目前为止我已经尝试过:
curl -H "Authorization: Bearer MY_ACCESS_TOKEN" https://MYINSTANCE.VisualStudio.com/DefaultCollection/_apis/projects?api-version=2.0
我一直在得到 "Object moved to ...." 结果。
我该如何解决这个问题?
我之前遇到过这个问题,通过将“Bearer”更改为“Basic”来解决这个问题。
curl -H "Authorization: Basic <TOKEN>" https://xxxxxx.VisualStudio.com/DefaultCollection/_apis/projects?api-version=2.0
更新: 目前,VSO Rest API 仅支持使用 OAuth 2.0 的基本身份验证和授权访问。您可以使用 Basic Auth 或使用 curl 从 VSO 获取 OAuth2.0 访问令牌。详见此link:Authorize access to REST APIs with OAuth 2.0。
我刚刚尝试使用个人访问令牌进行 DHC,但收到以下消息:"We are sorry, but Chrome API does not allow to get a response body for redirect." 因此您可能需要清除浏览器 cookie 和缓存,然后尝试查看承载是否可以与 VSO Rest 一起使用 API 在 DHC 中。
按照这里的精细手册:
https://docs.microsoft.com/en-us/rest/api/vsts/?view=vsts-rest-4.1
您可以按如下方式格式化您的 curl 请求(以下示例用于检索您的 VSTS 构建):
curl -u username:PATtoekn -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET https://your-account.visualstudio.com/your-project/_apis/build/builds?api-version=4.1 -k
祝你好运!