rest - 如何在不通知的情况下以编程方式(例如 Rest API)将用户添加到 AzureDevOps?
问题描述
我想以编程方式将用户添加到我的 Azure DevOps 服务组织,但他们不会收到通知。我已经开始使用User Entitlement Rest API编写如下脚本,但用户仍会收到通知:
$method = 'POST'
$devopsuri = "https://vsaex.dev.azure.com/<Devops org name>/_apis/userentitlements?api-version=5.1-preview.1"
$pat = "<pat>"
$encodedPat = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$pat"))
$header = @ {
Authorization = "Basic $encodedPat"
}
$body = @ {
"accessLevel" = @ {
"accountLicenseType" = "stakeholder"
}
"user" = @ {
"principalName" = "<UPN>"
"subjectKind" = "user"
}
} | ConvertTo - Json - Depth 5
$result = Invoke - RestMethod - Uri $devopsuri - Method $method - Headers $header - Body $body - UseBasicParsing - ContentType 'application/json'
https://stackoverflow.com/questions/ask#
解决方案
当我们不签Send email invites
入 UI 时,受邀者将不会收到通知。f12
所以我们可以通过在浏览器中按下来获取这个 api 。
Rest api:需要添加doNotSendInviteForNewUsers=true
到 url 和使用PATCH
方法。
PATCH https://vsaex.dev.azure.com/{org}/_apis/UserEntitlements?doNotSendInviteForNewUsers=true&api-version=5.1-preview.1
示例请求正文:
[{"from":"","op":0,"path":"","value":{"accessLevel":{"licensingSource":1,"accountLicenseType":2,"msdnLicenseType":0,"licenseDisplayName":"Basic","status":0,"statusMessage":"","assignmentSource":1},"user":{"principalName":"XXXX@outlook.com","subjectKind":"user"}}}]
我在邮递员中的测试:
推荐阅读
- docker - OWASP ZAP DOCKER - 扫描 url 列表
- python-3.x - Pytest:失败测试的拆解
- c# - 为什么不能隐式实现非公共接口成员?
- sql - 加入 2 个表,但结果中存在条件列中的所有值
- reactjs - 有没有办法避免使用 Tailwind 清除特定库?
- javascript - 从另一个域保存的 IndexedDB 中读取数据
- java - 使用 mockito [Spring-Boot] 测试 void 函数 try/catch 块
- reactjs - `react-hook-form` 在空输入时显示错误消息
- oracle - 子查询中的 Where 子句
- ruby-on-rails - 将 Rails 应用程序打包为 RPM 的 Rails 构建步骤