PowerBuilder
PowerBuilder
SugarCRM Logout
See more SugarCRM Examples
Demonstrates how to logout of a session.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Rest
oleobject loo_SbReq
oleobject loo_SbJson
oleobject loo_Json
li_Success = 0
loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest")
if li_rc < 0 then
destroy loo_Rest
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Rest.Connect("your.site.domain",443,1,1)
if li_Success <> 1 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
return
end if
loo_Rest.AddHeader("Cache-Control","no-cache")
loo_Rest.AddHeader("OAuth-Token","<access_token>")
loo_SbReq = create oleobject
li_rc = loo_SbReq.ConnectToNewObject("Chilkat.StringBuilder")
loo_SbJson = create oleobject
li_rc = loo_SbJson.ConnectToNewObject("Chilkat.StringBuilder")
li_Success = loo_Rest.FullRequestSb("POST","/rest/v10/oauth2/logout",loo_SbReq,loo_SbJson)
if li_Success <> 1 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
destroy loo_SbReq
destroy loo_SbJson
return
end if
if loo_Rest.ResponseStatusCode <> 200 then
Write-Debug "Received error response code: " + string(loo_Rest.ResponseStatusCode)
Write-Debug "Response body:"
Write-Debug loo_SbJson.GetAsString()
destroy loo_Rest
destroy loo_SbReq
destroy loo_SbJson
return
end if
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.LoadSb(loo_SbJson)
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
li_Success = loo_Json.BoolOf("success")
// A sample JSON response body that is parsed by the above code:
// {
// "success": true
// }
Write-Debug "Example Completed."
destroy loo_Rest
destroy loo_SbReq
destroy loo_SbJson
destroy loo_Json