我有以下部分lua脚本。
local config_string = [===[
]===]
local config = LuaConfig:new(config_string)
local request = LuaHttpRequest:new(config, "HTTP")
local username = "sss"
local password = "xxx"
request:set_header("Content-Type", "multipart/form-data")
request:set_header("Accept","application/json")
request:set_body("{\"RecordTitle\": { \"Value\": \"test vinay 344\" }, \"RecordRecordType\": \"2\", \"Fields\": { \"RoadSurface\" { \"Value\": \"smooth\" } } }")
request:set_url("http://ddddddd/CMServiceAPI/Record")
我如何执行基本身份验证?
我不知道您使用哪个库,但是像这样:
local username = "sss"
local password = "xxx"
local mime = require("mime")
request:set_header("authentication", "Basic " .. (mime.b64(username ..":" .. password)) )
request:set_header("content-type", "application/json" )
并且最后使用POST请求