(Go) SugarCRM Logout
Demonstrates how to logout of a session.
rest := chilkat.NewRest()
var success bool
success = rest.Connect("your.site.domain",443,true,true)
if success != true {
fmt.Println(rest.LastErrorText())
rest.DisposeRest()
return
}
rest.AddHeader("Cache-Control","no-cache")
rest.AddHeader("OAuth-Token","<access_token>")
sbReq := chilkat.NewStringBuilder()
sbJson := chilkat.NewStringBuilder()
success = rest.FullRequestSb("POST","/rest/v10/oauth2/logout",sbReq,sbJson)
if success != true {
fmt.Println(rest.LastErrorText())
rest.DisposeRest()
sbReq.DisposeStringBuilder()
sbJson.DisposeStringBuilder()
return
}
if rest.ResponseStatusCode() != 200 {
fmt.Println("Received error response code: ", rest.ResponseStatusCode())
fmt.Println("Response body:")
fmt.Println(*sbJson.GetAsString())
rest.DisposeRest()
sbReq.DisposeStringBuilder()
sbJson.DisposeStringBuilder()
return
}
json := chilkat.NewJsonObject()
json.LoadSb(sbJson)
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
var success bool
success = json.BoolOf("success")
// A sample JSON response body that is parsed by the above code:
// {
// "success": true
// }
fmt.Println("Example Completed.")
rest.DisposeRest()
sbReq.DisposeStringBuilder()
sbJson.DisposeStringBuilder()
json.DisposeJsonObject()
|