Sample code for 30+ languages & platforms
Lua

Send a Bodyless REST Request into a StringBuilder

See more REST Examples

Demonstrates Rest.FullRequestNoBodySb, which sends a request with no body and stores the text response body in a StringBuilder.

Background. This variant of the no-body full request writes the response into a StringBuilder rather than returning it as a string, which is convenient when the response will be further processed in place.

Chilkat Lua Downloads

Lua
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

-- FullRequestNoBodySb sends a request with no body and stores the text response body in a
-- StringBuilder.
local sbResponse = chilkat.StringBuilder.new()
success = rest:full_request_no_body_sb("GET", "/api/items/123", sbResponse)
if not success then
    print(rest.last_error_text)
    return
end

local responseText = sbResponse:get_as_string()
if not sbResponse.last_method_success then
    print(sbResponse.last_error_text)
    return
end

print(responseText)