You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用Google Cloud Logging entries:tail API始终返回INVALID_ARGUMENT错误

问题分析与解决

你的问题并非API本身存在问题,而是请求配置不符合接口要求导致的400错误,具体原因和修复方式如下:

核心错误点

entries:tail是基于**服务器发送事件(SSE)**的流式接口,并非常规JSON接口,你设置的Accept: application/json请求头不符合接口要求,这是触发错误的主要原因。

修复后的curl命令

将Accept头改为text/event-stream,同时确保Bearer令牌有效:

curl -s \
    -H 'authorization: Bearer 你的有效令牌' \
    -H 'accept: text/event-stream' \
    -H 'content-type: application/json' \
    --data-binary '{"resourceNames":["projects/del-test-x"]}' \
    --compressed 'https://logging.googleapis.com/v2/entries:tail'

补充说明

该接口会以SSE格式持续返回新增的日志条目,而非一次性返回JSON响应。若需停止流式传输,直接中断curl进程即可。

内容的提问来源于stack exchange,提问作者zino

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 08:52:06