title: Dart: HTTP GET with Header
body: <p>I'm working on creating a Flutter application that works with LIFX. I'm trying to follow their instructions <a href="https://lifx.readme.io/docs/list-lights" rel="noreferrer">here</a>, but I'm having issues adding a header to my HTTP GET request.</p>
  
  <pre><code>TestHttpGet() async {
    var httpClient = new HttpClient();
    var header = "Bearer $token"; //token hidden
    var url = 'https://api.lifx.com/v1/lights/all/state';
  
    String result;
    try {
      var request = await httpClient.getUrl(Uri.parse(url));
      request.headers.set("Authorization", header);
      var response = await request.close();
      if (response.statusCode == HttpStatus.OK) {
            var json = await response.transform(UTF8.decoder).join();
            print(json);
            var data = JSON.decode(json);
            result = data['brightness'].toString();
          } else {
            result =
                'Error getting response:\nHttp status ${response.statusCode}';
          }
        } catch (exception) {
          result = 'Failed parsing response';
        }
  </code></pre>
  
  <p>This returns with <code>Error getting response: Http status 404</code>. I've tried various ways of <code>request.headers .set .add [HttpHeaders.Authorization] = "header"</code> all return with a 404. Any advice would be appreciated.</p>