【问题标题】:Check if current user has permissions to create work items检查当前用户是否有权创建工作项
【发布时间】:2021-06-15 16:48:52
【问题描述】:

TFS rest api 中是否有一个端点可以用来检查当前登录的用户是否有足够的权限来创建一个新的 TFS 工作项?

【问题讨论】:

  • 嗨@Ridene Mohamed Aziz。这张票有更新吗?如果 Shamrai Aleksander 的回答可以解决这个问题,请随时告诉我。如果是,您可以考虑接受它作为答案

标签: api tfs azure-devops


【解决方案1】:

尝试使用带有validateOnly 参数Work Items - Create 的验证。 PowerShell 示例:

$pat = '<pat>'
$url = 'https://dev.azure.com/<org>/<project>/_apis/wit/workitems/$Task?validateOnly=true&api-version=6.1-preview.3'


$body = '[{"op":"add","path":"/fields/System.Title","from":null,"value":"Sample task"}]'


$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f "",$pat)))

Invoke-RestMethod -Uri $url -Method Post -ContentType "application/json-patch+json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Body $body

结果:

Invoke-RestMethod : {"$id":"1","innerException":null,"message":"TF237111: The current user does not have permissions to save work items under the specified area path.","typeName":"Microsoft.Azure.Boards.WebApi.Com
mon.PermissionDeniedException, Microsoft.Azure.Boards.WebApi.Common","typeKey":"PermissionDeniedException","errorCode":0,"eventId":3000}
At line:10 char:1
+ Invoke-RestMethod -Uri $url -Method Post -ContentType "application/js ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

【讨论】:

    猜你喜欢
    • 2013-09-13
    • 1970-01-01
    • 2012-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多