【问题标题】:Update license level using Azure DevOps REST API使用 Azure DevOps REST API 更新许可证级别
【发布时间】:2019-11-27 19:23:39
【问题描述】:

我正在使用邮递员进行测试,以使用 REST API 更新 Azure DevOps 中的许可级别。我正在使用以下 POST URL:

https://vsaex.dev.azure.com/sandbox-org/_apis/userentitlements/88d3bc6c-0eb1-481b-bea0-8fbf3a5e054c?api-version=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
}

【问题讨论】:

    标签: azure-devops azure-devops-rest-api


    【解决方案1】:

    如果您想将级别更改为基本,请使用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
    

    【讨论】:

      猜你喜欢
      • 2021-08-05
      • 2022-08-12
      • 1970-01-01
      • 1970-01-01
      • 2022-07-17
      • 2020-06-12
      • 2019-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多