I am trying to post data to API. I am building request every time. and I am adding headers to wrk.format()
method. The headers are not accepting event though headers type is string.
headers = {}
s = {}
request = function()
headers["Authorization"] = "key"
for name, value in pairs(headers) do
s[1] = string.format("%s: %s", name, value)
end
print(s[1])
print(type(s[1])
return wrk.format("POST", "/api/", s[1] ,data)
end
throwing error :
PANIC: unprotected error in call to Lua API ([string "wrk"]:0: attempt to index field 'headers' (a string value))
Can anyone help me with this?
Thanks in advance.