Sample code for 30+ languages & platforms
Lua

SugarCRM Logout

See more SugarCRM Examples

Demonstrates how to logout of a session.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local rest = chilkat.Rest.new()

local success = rest:connect("your.site.domain", 443, true, true)
if not success then
    print(rest.last_error_text)
    return
end

rest:add_header("Cache-Control", "no-cache")
rest:add_header("OAuth-Token", "<access_token>")

local sbReq = chilkat.StringBuilder.new()

local sbJson = chilkat.StringBuilder.new()
success = rest:full_request_sb("POST", "/rest/v10/oauth2/logout", sbReq, sbJson)
if not success then
    print(rest.last_error_text)
    return
end

if rest.response_status_code ~= 200 then
    print("Received error response code: " .. rest.response_status_code)
    print("Response body:")
    print(sbJson:get_as_string())
    return
end

local json = chilkat.JsonObject.new()
json:load_sb(sbJson)

-- The following code parses the JSON response.
-- A sample JSON response is shown below the sample code.

success = json:bool_of("success")

-- A sample JSON response body that is parsed by the above code:

-- {
--   "success": true
-- }

print("Example Completed.")