(AutoIt) SugarCRM Logout
Demonstrates how to logout of a session.
$oRest = ObjCreate("Chilkat.Rest")
Local $bSuccess
$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.
Local $bSuccess
$bSuccess = $oJson.BoolOf("success")
; A sample JSON response body that is parsed by the above code:
; {
; "success": true
; }
ConsoleWrite("Example Completed." & @CRLF)
|