Lua-cURLv3 icon indicating copy to clipboard operation
Lua-cURLv3 copied to clipboard

How can I post json data?

Open zacard-orc opened this issue 1 year ago • 2 comments

I browsed the official document,but i can't found any info about postjson.

I try this way,but no effect,

local post_data = {
   sn = sn
}
local headers = {}
headers["Content-Type"] = "application/json;charset=utf-8"
headers["Accept"] = "application/json"

local postdata_json = json.encode(post_data)
c:setopt_httpheader(headers)
c:setopt_postfields(postdata_json)
c:setopt_writefunction(function(response_data)
   alert(response_data) 
end)

c:perform()
c:close()

can u help me ,give a sample?

zacard-orc avatar Jan 30 '24 08:01 zacard-orc

Hey buddy, did you try adding c:setopt_post(true) somewhere already?

NTBBloodbath avatar Jan 30 '24 20:01 NTBBloodbath