Dart
Dart
SugarCRM Logout
See more SugarCRM Examples
Demonstrates how to logout of a session.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
final rest = CkRest();
try {
rest.connect('your.site.domain', 443, true, true);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
rest.addHeader('Cache-Control', 'no-cache');
rest.addHeader('OAuth-Token', '<access_token>');
final sbReq = CkStringBuilder();
final sbJson = CkStringBuilder();
try {
rest.fullRequestSb('POST', '/rest/v10/oauth2/logout', sbReq, sbJson);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
if (rest.responseStatusCode != 200) {
print('Received error response code: ${rest.responseStatusCode}');
print('Response body:');
print(sbJson.getAsString());
return;
}
final json = CkJsonObject();
json.loadSb(sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
json.boolOf('success');
// A sample JSON response body that is parsed by the above code:
// {
// "success": true
// }
print('Example Completed.');
}