Sample code for 30+ languages & platforms
Dart

qa.factura1.com.co Obtain Auth Token

See more HTTP Misc Examples

Demonstrates how to send a JSON POST to get an authenticataion token for qa.factura1.com.co

Chilkat Dart Downloads

Dart
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();

  // Build the following JSON
  // {
  //   "password": "MY_PASSWORD",
  //   "username": "MY_USERNAME"
  // }

  final json = CkJsonObject();
  json.emitCompact = false;
  json.updateString('password', 'MY_PASSWORD');
  json.updateString('username', 'MY_USERNAME');

  final resp = CkHttpResponse();
  try {
    http.httpJson('POST', 'https://qa.factura1.com.co/v2/auth', json, 'application/json', resp);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final jsonResp = CkJsonObject();
  jsonResp.emitCompact = false;
  jsonResp.load(resp.bodyStr);

  print(jsonResp.emit());

  print('Access token: ${jsonResp.stringOf('token')}');
}