Lua
Lua
Clear All Multipart Parts
See more REST Examples
Demonstrates Rest.ClearAllParts, which removes all multipart subparts from the request under construction.
Background. Clearing the parts is useful when reusing the same Rest object to build a different multipart request.
Chilkat Lua Downloads
local chilkat = require("chilkat")
local rest = chilkat.Rest.new()
local bTls = true
local bAutoReconnect = true
local success = rest:connect("example.com", 443, bTls, bAutoReconnect)
if not success then
print(rest.last_error_text)
return
end
-- Build a part.
rest.part_selector = "1"
success = rest:set_multipart_body_string("value1")
if not success then
print(rest.last_error_text)
return
end
-- Remove all multipart subparts from the request under construction, for example before reusing the
-- same Rest object for a different multipart request.
rest:clear_all_parts()
print("All multipart parts cleared.")