简体   繁体   English

通过REST API调用获取TFS仪表板小部件ID

[英]Getting TFS dashboard widget ID with REST API call

I want to get the id of a widget, because I need to pass it to a web service when the user saves the configuration. 我想要获取小部件的ID,因为当用户保存配置时,我需要将其传递给Web服务。 I have found out, there is a REST API service for this. 我发现,为此提供了一个REST API服务。 If I enter the following URL in my browser (substituting specific info in the brackets of course): 如果我在浏览器中输入以下URL(当然,请在方括号中替换特定信息):

https://{account}.VisualStudio.com/DefaultCollection/{project}/{teamId}/_apis/dashboard/dashboards/{dashboardId}/widgets/{id}?api-version={version}

it works fine, however I get an HTTP 401 (Unauthorized) error when I try to make an ajax get request from the javascript code of the widget. 它工作正常,但是当我尝试从小部件的javascript代码发出ajax获取请求时,出现HTTP 401(未经授权)错误。

Any ideas? 有任何想法吗?

401 HTTP status means that you either are not authenticated with the API or are not authorized to perform a particular operation. 401 HTTP状态表示您未通过API进行身份验证或未获得执行特定操作的权限。 TFS Rest API from what I can see allows two types of authentication: 从我看到的TFS Rest API可以看到两种身份验证:

The documentation of the API at https://www.visualstudio.com/en-us/docs/integrate/extensions/overview explains it quite well and provides CURL commandline examples. https://www.visualstudio.com/zh-cn/docs/integrate/extensions/overview上的API文档对此进行了很好的说明,并提供了CURL命令行示例。 Go and have a look. 去看看吧

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM