http 

Send to Kindle
home » snippets » dart » http



Examples

POST from a command line app

import 'dart:io';
import 'dart:convert' show UTF8, JSON;

main() {
  Uri url = Uri.parse("http://ng-dash.gae.localhost/api/run");
  new HttpClient().postUrl(url)
      .then((HttpClientRequest request) {
          request.headers.contentType = ContentType.JSON;
          request.write(JSON.encode({"commitSha": "d1"}));
          return request.close();
      })
      .then((HttpClientResponse response) {
          response.transform(UTF8.decoder).listen((contents) {
              print(contents);
          });
      });
}