Dart
Dart
List all Labels in the User's Mailbox
See more GMail REST API Examples
List all Labels in the GMail User's MailboxChilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final http = CkHttp();
http.authToken = 'GMAIL-ACCESS-TOKEN';
final userId = 'me';
http.setUrlVar('userId', userId);
final url = 'https://www.googleapis.com/gmail/v1/users/{\$userId}/labels';
http.sessionLogFilename = 'c:/temp/qa_output/sessionLog.txt';
// Get the list of GMail labels as JSON.
final sb = CkStringBuilder();
try {
http.quickGetSb(url, sb);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final json = CkJsonObject();
json.loadSb(sb);
json.emitCompact = false;
print(json.emit());
if (http.lastStatus != 200) {
print('Failed.');
return;
}
}