Microsoft Flow调用Graph API分配用户许可证遇405错误求助
问题排查与解决方案
核心问题分析
- HTTP方法错误:Microsoft Graph API中,为用户分配/更新许可证的正确HTTP方法是
PUT,而非你当前使用的POST。/users/{id}/assignedLicenses端点仅支持PUT操作来修改用户的许可证分配。 - 请求体无效数据:你的
addLicenses数组中包含一个skuId为空的条目,这属于无效的许可证参数,会导致请求被拒绝。
修正后的请求示例
请求输入(已修正)
{ "uri": "https://graph.microsoft.com/v1.0/users/67a9cbf3-d55b-47b3-b0d2-be1ba01f683d/assignedLicenses", "method": "PUT", "authentication": { "authority": "https://login.microsoftonline.com", "tenant": "Tenant ID", "audience": "https://graph.microsoft.com", "clientId": "Secret ID", "secret": "*sanitized*", "type": "ActiveDirectoryOAuth" }, "body": { "addLicenses": [ { "disabledPlans": [], "skuId": "f30db892-07e9-47e9-837c-80727f46fd3d" } ], "removeLicenses": [] } }
额外验证点
- 确认
skuId对应的许可证在你的租户中可用,且有剩余配额。 - 确保应用已正确授予
User.ReadWrite.All或Directory.ReadWrite.All权限,且权限已被管理员同意(委派权限需要用户登录,应用权限需要管理员同意)。
内容的提问来源于stack exchange,提问作者lombahdo
相关产品推荐
相关产品推荐

