Lua Requires Chilkat v11.0.0+
/:record endpoint, by using the DELETE Http Method.
Lua
SugarCRM Deleting a Record
See more SugarCRM Examples
Deletes a record from the Sugar instance using the /Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local http = chilkat.Http.new()
-- Implements the following CURL command:
-- curl -X DELETE -H OAuth-Token:<access_token> -H Cache-Control:no-cache http://<site_url>/rest/v10/Accounts/<record_id>
http:set_request_header("Cache-Control", "no-cache")
http:set_request_header("OAuth-Token", "<access_token>")
local resp = chilkat.HttpResponse.new()
local success = http:http_no_body("DELETE", "http://<site_url>/rest/v10/Accounts/<record_id>", resp)
if not success then
print(http.last_error_text)
return
end
local sbResponseBody = chilkat.StringBuilder.new()
resp:get_body_sb(sbResponseBody)
local jResp = chilkat.JsonObject.new()
jResp:load_sb(sbResponseBody)
jResp.emit_compact = false
print("Response Body:")
print(jResp:emit())
local respStatusCode = resp.status_code
print("Response Status Code = " .. respStatusCode)
if respStatusCode >= 400 then
print("Response Header:")
print(resp.header)
print("Failed.")
return
end
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "id": "ab2222df-73da-0e92-6887-5705428f4d68"
-- }
-- Sample code for parsing the JSON response...
-- Use the following online tool to generate parsing code from sample JSON:
-- Generate Parsing Code from JSON
local id = jResp:string_of("id")