Go
/:record endpoint, by using the DELETE Http Method.
Go
SugarCRM Deleting a Record
See more SugarCRM Examples
Deletes a record from the Sugar instance using the /Chilkat Go Downloads
success := false
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := chilkat.NewHttp()
// 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.SetRequestHeader("Cache-Control","no-cache")
http.SetRequestHeader("OAuth-Token","<access_token>")
resp := chilkat.NewHttpResponse()
success = http.HttpNoBody("DELETE","http://<site_url>/rest/v10/Accounts/<record_id>",resp)
if success == false {
fmt.Println(http.LastErrorText())
http.DisposeHttp()
resp.DisposeHttpResponse()
return
}
sbResponseBody := chilkat.NewStringBuilder()
resp.GetBodySb(sbResponseBody)
jResp := chilkat.NewJsonObject()
jResp.LoadSb(sbResponseBody)
jResp.SetEmitCompact(false)
fmt.Println("Response Body:")
fmt.Println(*jResp.Emit())
respStatusCode := resp.StatusCode()
fmt.Println("Response Status Code = ", respStatusCode)
if respStatusCode >= 400 {
fmt.Println("Response Header:")
fmt.Println(resp.Header())
fmt.Println("Failed.")
http.DisposeHttp()
resp.DisposeHttpResponse()
sbResponseBody.DisposeStringBuilder()
jResp.DisposeJsonObject()
return
}
// 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
var id *string = new(string)
id = jResp.StringOf("id")
http.DisposeHttp()
resp.DisposeHttpResponse()
sbResponseBody.DisposeStringBuilder()
jResp.DisposeJsonObject()