如何在VSTS Graph api组列表查询中使用scopeDescriptor和subjectTypes? [英] How to use scopeDescriptor and subjectTypes in VSTS Graph api groups list query?

查看:45
本文介绍了如何在VSTS Graph api组列表查询中使用scopeDescriptor和subjectTypes?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过名称解析特定的VSTS组,以检索identityDescriptor属性.我想查询支持的查询参数,而不是查询所有组和过滤器.查看 VSTS组-列表API ,它支持其他查询参数scopeDescriptor和subjectType.但是,我一直在为这些参数提供错误的值.

I am trying to resolve a particular VSTS group by name to retrieve the identityDescriptor property. Rather than query all groups and filter, I want to leverage the query parameters supported. Looking at VSTS Groups - List API, it supports the additional query parameters scopeDescriptor, and subjectType. However, I keep providing bad values for these parameters.

但是,当我指定这些的任何组合时,我得到0个结果.另外,一旦我添加了scopeDescriptor,我就点击了Microsoft.VisualStudio.Services.Graph.InvalidSubjectTypeException-> HTTP 400错误请求.

However, when I specify any combination of these I get 0 results. In addition, as soon as I add a scopeDescriptor, I hit an Microsoft.VisualStudio.Services.Graph.InvalidSubjectTypeException -> HTTP 400 Bad Request.

问题:

  1. subjectTypes的期望值的示例有哪些?

编辑1 subjectTypes不是实际的类型,而是在主题描述符之前加上前缀的子类型.例如-> vssgp,aadgp:

Edit 1 subjectTypes are not the actual type, but the subtype that prefixes the subject descriptor. For example -> vssgp,aadgp:

"subjectDescriptor": "vssgp.Dc0NDgzLTzQ1NwOTI5LTI0NTcwNDLTAtMwUy0xLTktMTAtMC0wMjgxNjcxNDU0OS0zMU1MTM3NDI0NS0yMjUzNzA0ODMtE"

  1. scopeDescriptor期望值的例子有哪些?

示例查询网址:

 - Working:
   https://{account}.vssps.visualstudio.com/_apis/graph/groups?api-version=4.1-preview.1

 - Working subjectTypes:
   https://{account}.vssps.visualstudio.com/_apis/graph/groups?subjectTypes=vssgp&api-version=4.1-preview.1

 - scopeDescriptor throws:
   https://{account}.vssps.visualstudio.com/_apis/graph/groups?scopeDescriptor=collection&api-version=4.1-preview.1
   https://{account}.vssps.visualstudio.com/_apis/graph/groups?scopeDescriptor=collection&subjectTypes=Microsoft.TeamFoundation.Identity&api-version=4.1-preview.1

推荐答案

您可以通过向 https://vssps.dev.azure.com/发出api请求来获取项目或集合的范围描述符.{organization}/_ apis/graph/descriptors/{Id} (如果要获取项目的范围描述符,请用projectId替换ID.

You can get the scope descriptors for a project or a collection by making an api request to https://vssps.dev.azure.com/{organization}/_apis/graph/descriptors/{Id}(replace id with projectId if you want to get the scope descriptor for a project and so on).

例如,如果要获取项目的范围描述符,则只需将请求URL中的存储密钥替换为项目ID,并作为响应即可获得范围描述符.范围描述符具有以下格式scp.(长唯一标识符).

For example if you want to get the scope descriptor for a project then simply replace the storage key in the request URL with the project Id and in response you get the scope descriptor. The scope descriptor has the following format scp.(long unique identifier).

PS:有关如何获取描述符的更多信息,请参见

P.S: More on how to get descriptors can be found here https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/descriptors/get?view=azure-devops-rest-5.0. Remember storagekey can be substituted with projectid or collectionid to get specific descriptors.

这篇关于如何在VSTS Graph api组列表查询中使用scopeDescriptor和subjectTypes?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆