Azure devops 使用Azure DevOps REST API更新许可证级别
我正在使用postman进行测试,以使用RESTAPI更新Azure DevOps中的许可级别。我正在使用以下帖子URL:Azure devops 使用Azure DevOps REST API更新许可证级别,azure-devops,azure-devops-rest-api,Azure Devops,Azure Devops Rest Api,我正在使用postman进行测试,以使用RESTAPI更新Azure DevOps中的许可级别。我正在使用以下帖子URL: https://vsaex.dev.azure.com/sandbox-org/_apis/userentitlements/88d3bc6c-0eb1-481b-bea0-8fbf3a5e054c?api-版本=5.0-preview.2 以下内容作为正文传递: [ { "from": "", "op": "replace", "path":
https://vsaex.dev.azure.com/sandbox-org/_apis/userentitlements/88d3bc6c-0eb1-481b-bea0-8fbf3a5e054c?api-版本=5.0-preview.2
以下内容作为正文传递:
[
{
"from": "",
"op": "replace",
"path": "/accessLevel",
"value": {
"accountLicenseType": "basic",
"licensingSource": "account"
}
}
]
我收到以下400条错误请求消息。有没有解决这个问题的办法
{
"$id": "1",
"innerException": null,
"message": "Value cannot be null.\r\nParameter name: userEntitlement",
"typeName": "System.ArgumentNullException, mscorlib",
"typeKey": "ArgumentNullException",
"errorCode": 0,
"eventId": 0
}
如果要将级别更改为基本,请使用
express
:“accountLicenseType”:“express”,而不是此“accountLicenseType”:“Basic”
但您遇到的错误与此无关,您没有编写所有尝试的脚本,因此很难找到问题,但我成功地使用此PowerShell脚本更改了级别:
$user = ""
$token = "MY-PAT"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
$url = "https://vsaex.dev.azure.com/{organization}/_apis/userentitlements/{user-Guid}?api-version=5.0-preview.2"
$body = @"
[
{
"from": "",
"op": "replace",
"path": "/accessLevel",
"value": {
"accountLicenseType": "express",
"licensingSource": "account"
}
}
]
"@
Invoke-RestMethod -Uri $url -Method Patch -ContentType application/json-patch+json -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Body $body