Sample code for 30+ languages & platforms
Dart

Send a Bodyless REST Request into a StringBuilder

See more REST Examples

Demonstrates Rest.FullRequestNoBodySb, which sends a request with no body and stores the text response body in a StringBuilder.

Background. This variant of the no-body full request writes the response into a StringBuilder rather than returning it as a string, which is convenient when the response will be further processed in place.

Chilkat Dart Downloads

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

void main() {
  final rest = CkRest();
  final bTls = true;
  final bAutoReconnect = true;
  try {
    rest.connect('example.com', 443, bTls, bAutoReconnect);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  // FullRequestNoBodySb sends a request with no body and stores the text response body in a
  // StringBuilder.
  final sbResponse = CkStringBuilder();
  try {
    rest.fullRequestNoBodySb('GET', '/api/items/123', sbResponse);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final String responseText;
  try {
    responseText = sbResponse.getAsString();
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  print(responseText);
}