lua-resty-http POST body request, 返回 unknow params

29 views
Skip to first unread message

jet li

unread,
Oct 29, 2022, 11:32:41 AM10/29/22
to openresty
飞书官方机器人POST 请求:

{
    "timestamp": "15900000001",
    "sign": "xxxxxxxxxxxxxxxxxxxxx",
    "msg_type": "text",
    "content": {
        "text": "request example"
    }


lua :
local body = {}
table.insert(body, "timestamp=" ..  tostring(time_))
table.insert(body, "&sign=" .. tostring(sign))
table.insert(body, "&msg_type=" .. "\"text\"")
table.insert(body, "&content={text=\"hello\"}")
local http = require "resty.http"
local httpc,err = http.new()
local res, err = httpc:request_uri("https://aaa.bbb.cn",{
            method = "POST",
            path = "/c15f7e3a6",
            body = body,
            headers = {
                ["Content-Type"] = "application/x-www-form-urlencoded",
                --["Content-Type"] = "application/json",
            },
    })

Response:{"msg":"params error, unknown content value"}

body:timestamp=11111111&sign=2323423sdkfjl=&msg_type="text"&content={text="hello"}

jet li

unread,
Oct 30, 2022, 7:18:51 AM10/30/22
to openresty
请教下各位大佬,我在用 openresty 发送POST 请求,参数嵌套了 key-vaule ,返回  unknown content value,我知道 lua table 可以是整数,字符串,key-value ,不知道 key: { key: value} 怎样支持呢

Junlong li

unread,
Nov 10, 2022, 8:12:01 AM11/10/22
to openresty
你要的是json格式的数据吗?如果是的话以用cjson.encode
Reply all
Reply to author
Forward
0 new messages