使用 Google Enterprise License Manager API 插入 G Suite licenseAssignment 时出现错误 400 "Invalid JSON payload"

Error 400 "Invalid JSON payload" when inserting G Suite licenseAssignment with Google Enterprise License Manager API

多年来,我一直在使用 Google Apps 脚本中的 Google Enterprise License Manager API 成功地为用户分配 G Suite 许可证。自上周五,2020 年 4 月 24 日以来,我一直从 API.

返回 Invalid JSON payload 错误

我创建此对象以插入许可分配:

{
  "userId": "user@domain.com",
  "productId": "Google-Apps",
  "skuId": "Google-Apps-Unlimited"
}

我使用 UrlFetchApp 从 Google Apps 脚本调用 API:

{
  "url": "https://www.googleapis.com/apps/licensing/v1/product/Google-Apps/sku/Google-Apps-Unlimited/user",
  "validateHttpsCertificates": true,
  "followRedirects": true,
  "payload": "{\"userId\":\"user@domain.com\",\"productId\":\"Google-Apps\",\"skuId\":\"Google-Apps-Unlimited\"}",
  "useIntranet": false,
  "headers": {
    "Authorization": "Bearer ya29.xxxx",
    "X-Forwarded-For": "x.x.x.x"
  },
  "method": "post",
  "contentType": "application/json"
}

通常这行得通,但现在我收到了这样的回复:

{
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unknown name \"productId\" at 'body': Cannot find field.\nInvalid JSON payload received. Unknown name \"skuId\" at 'body': Cannot find field.",
    "errors": [
      {
        "message": "Invalid JSON payload received. Unknown name \"productId\" at 'body': Cannot find field.\nInvalid JSON payload received. Unknown name \"skuId\" at 'body': Cannot find field.",
        "reason": "invalid"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

我已经确认:

根据 Google 的开发人员指南,我在这里提出了这个问题并在 Google Apps Script IssueTracker 中提交了 issue

根据 documentation,有效载荷应仅包含 userIdproductIdskuId 只是路径参数,将其包含在 url 中就足够了。

请求正文:

{
  "userId": string
}