用途:诊断阿里云 OpenAPI 调用失败。借助 OpenAPI Explorer 排查接口(以 Aliyun CLI 命令形式提供),查询请求日志、分析失败原因并获取官方错误码解决方案。
前置条件:安装 Aliyun CLI,运行 aliyun version 确认版本不低于 3.4.0;安装 openapiexplorer 插件(必需),插件名为 aliyun-cli-openapiexplorer。安装与校验命令: aliyun configure set --auto-plugin-install true aliyun plugin install --names aliyun-cli-openapiexplorer aliyun plugin update aliyun plugin list | grep openapiexplorer aliyun openapiexplorer get-own-request-log --help
凭据检查:运行 aliyun configure list 确认已配置。禁止读取、回显或索要 AK/SK,仅通过该命令检查状态,输出日志时需脱敏。
主要能力:三条命令分别对应 GetOwnRequestLog(当前账号请求日志)、GetRequestLog(同一父账号下主账号及子账号请求日志)、GetErrorCodeSolutions(错误码诊断方案)。调用云 API 的命令必须携带 --user-agent AlibabaCloud-Agent-Skills/alibabacloud-error-troubleshoot/{session-id},session-id 为会话开始时生成一次的 32 位小写十六进制字符串。
诊断流程:有 Request ID 时先用 get-own-request-log 查询日志(涉及主账号或同父子账号用 get-request-log),从 logInfo.basicInfo 提取 errorCode、errorMessage、product,再调用 get-error-code-solutions;无 Request ID 仅有错误码时直接查询方案。
限制:若返回 NotFound.RequestLog(404),表示日志不可用(约 3 天过期、范围不符或无权限),必须终止流程,禁止将该状态码传给 get-error-code-solutions。权限不足时参考 RAM 策略,不得未经确认切换账号。