Sample code for 30+ languages & platforms
B4X

SugarCRM Logout

See more SugarCRM Examples

Demonstrates how to logout of a session.

Chilkat B4X Downloads

B4X
Dim success As Boolean = False

Dim rest As ChilkatRest
rest.Initialize("rest")

success = rest.Connect("your.site.domain", 443, True, True)
If success <> True Then
    Log(rest.LastErrorText)
    Return
End If


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

Dim sbReq As ChilkatStringBuilder
sbReq.Initialize

Dim sbJson As ChilkatStringBuilder
sbJson.Initialize
success = rest.FullRequestSb("POST", "/rest/v10/oauth2/logout", sbReq, sbJson)
If success <> True Then
    Log(rest.LastErrorText)
    Return
End If


If rest.ResponseStatusCode <> 200 Then
    Log("Received error response code: " & rest.ResponseStatusCode)
    Log("Response body:")
    Log(sbJson.GetAsString)
    Return
End If


Dim json As ChilkatJsonObject
json.Initialize
json.LoadSb(sbJson)

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

success = json.BoolOf("success")

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

'  {
'    "success": true
'  }

Log("Example Completed.")