Sample code for 30+ languages & platforms
Dart

Clickatell Get Message Status

See more Clickatell Examples

This API method will return the status of the given message ID.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  // This example assumes the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  final http = CkHttp();

  // Implements the following CURL command:

  // curl -X GET --header 'Accept: application/json' \
  //   --header 'Authorization: API_KEY' \
  //    https://platform.clickatell.com/public-client/message/status?messageId=MESSAGE_ID

  http.setRequestHeader('Authorization', 'API_KEY');
  http.setRequestHeader('Accept', 'application/json');

  final sbResponseBody = CkStringBuilder();
  try {
    http.quickGetSb('https://platform.clickatell.com/public-client/message/status?messageId=MESSAGE_ID', sbResponseBody);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final jResp = CkJsonObject();
  jResp.loadSb(sbResponseBody);
  jResp.emitCompact = false;

  print('Response Body:');
  print(jResp.emit());

  final respStatusCode = http.lastStatus;
  print('Response Status Code = $respStatusCode');
  if (respStatusCode >= 400) {
    print('Response Header:');
    print(http.lastHeader);
    print('Failed.');
    return;
  }

  // Sample JSON response:
  // (Sample code for parsing the JSON response is shown below)

  // {
  //   "status example": "QUEUED"
  // }

  // Sample code for parsing the JSON response...
  // Use the following online tool to generate parsing code from sample JSON:
  // Generate Parsing Code from JSON

  final statusExample = jResp.stringOf('status example');
}