AutoJs6 icon indicating copy to clipboard operation
AutoJs6 copied to clipboard

为什么post请求,headers带不进去?

Open wengzhenquan opened this issue 8 months ago • 2 comments

` // 发送请求

    let res = http.post(OPENAI_URL, {
        headers: {
            "Content-Type": "application/json",
            "Authorization": `Bearer ${OPENAI_API_KEY}`
        },
        body: {
            model: "gpt-4-vision-preview", // 使用支持图片的模型
            messages: messages,
            max_tokens: 1000
        }
    });

    let result = res.body.json();

`

GPT回复: { code: 9, msg: no header: Authorization. api doc: https://doc.zhizengzeng.com, error: { message: no header: Authorization. api doc: https://doc.zhizengzeng.com, type: invalid_request_error } }

wengzhenquan avatar Apr 08 '25 17:04 wengzhenquan

Image

可尝试按照上述代码使用 http.post 方法发送请求.

SuperMonster003 avatar Apr 08 '25 23:04 SuperMonster003

和楼主相同的问题,求解决 @SuperMonster003

xinzezhu avatar May 02 '25 15:05 xinzezhu