title: Flutter - How to send a POST request using HTTP in Dart?
body: <p>I am using an API that converts HTTP to JSON and to get a response from the server I need to send a post request of HTML however i'm not sure how to do that?</p>
  <p>This is my current implementation -</p>
  <pre><code>Future&lt;String&gt; test() async {
    var link =
        await http.get('https://example.com');
    var body = parse(link.body);
    return body.outerHtml;
  }
  
  Future&lt;Album&gt; createAlbum(String html) async {
    final http.Response response = await http.post(
      'https://www.html2json.com/api/v1',
      headers: &lt;String, String&gt;{
        'Content-Type': 'text/html; charset=UTF-8',
      },
    
      body: html,
    );
  
    if (response.statusCode == 200) {
      return Album.fromJson(jsonDecode(response.body));
    } else {
      throw Exception('Failed to create album.');
    }
  }
  </code></pre>
  <p>I call this is when my app starts like so,</p>
  <pre><code>@ovveride 
  void initState() {
  test().then((body) =&gt; createAlbum(body)); //Output returns HTTP error 301, am I doing something wrong?
  super.initState();
  }
  </code></pre>