【发布时间】:2020-08-12 17:10:44
【问题描述】:
多年来,我一直在使用 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"
}
}
我已经确认:
我们的域有 G Suite Business 许可证,我的帐户是超级管理员帐户,并且我已在 GCP 控制台中启用 Enterprise License Manager API。
我正在使用此处定义的正确 API 端点 URL 和路径参数:LicenseAssignments: insert
userId、productId和skuId包含在 JSON 有效负载中我在此处定义的域中使用正确的
productId和skuId:Google Product and SKU IDs用户存在于我们的 G Suite 域中
这会影响我测试过的多个用户,包括有和没有当前许可证分配的用户
根据 Google 的开发者指南,我已经在这里提出了这个问题,并在 Google Apps Script IssueTracker 中提交了issue。
【问题讨论】:
-
顺便说一句,包含所有细节、链接和研究的优秀问题。
标签: json google-apps-script google-license-manager google-workspace