Sample code for 30+ languages & platforms
AutoIt

SugarCRM Logout

See more SugarCRM Examples

Demonstrates how to logout of a session.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

$oRest = ObjCreate("Chilkat.Rest")

$bSuccess = $oRest.Connect("your.site.domain",443,True,True)
If ($bSuccess <> True) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

$oRest.AddHeader("Cache-Control","no-cache")
$oRest.AddHeader("OAuth-Token","<access_token>")

$oSbReq = ObjCreate("Chilkat.StringBuilder")

$oSbJson = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oRest.FullRequestSb("POST","/rest/v10/oauth2/logout",$oSbReq,$oSbJson)
If ($bSuccess <> True) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

If ($oRest.ResponseStatusCode <> 200) Then
    ConsoleWrite("Received error response code: " & $oRest.ResponseStatusCode & @CRLF)
    ConsoleWrite("Response body:" & @CRLF)
    ConsoleWrite($oSbJson.GetAsString() & @CRLF)
    Exit
EndIf

$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.LoadSb($oSbJson)

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

$bSuccess = $oJson.BoolOf("success")

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

; {
;   "success": true
; }

ConsoleWrite("Example Completed." & @CRLF)