title: Flutter - Send Json over HTTP Post
body: <p>I am trying to send a Json over HTTP post to update a record in my database. I've connected to the server but I'm getting a 415 "Unsupported Media Type" error when I run the request.</p>
  
  <pre><code>import 'dart:async';
  import 'dart:convert';
  import 'package:flutter/material.dart';
  import 'package:http/http.dart' as http;
  
  void main() =&gt; runApp(new MyApp());
  
  class MyApp extends StatelessWidget {
  
  @override
  Widget build(BuildContext context) {
  return new MaterialApp(
    home: new MyHomePage(),
  );
  }
  }
  
  class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() =&gt; new _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
  String url = 'http://&lt;Hostname&gt;: 
  &lt;Port&gt;/jderest/orchestrator/JDE_ORCH_Sample_UpdateMeterReadings_Generic';
  
  
  Future&lt;String&gt; makeRequest() async {
  var response = await http
      .post(Uri.encodeFull(url), body: json.encode({
    "NewHourMeterReading": "650",
    "EquipmentNumber": "34665",
    "NewFuelMeterReading": "650"
  }), headers: {"Accept": "application/json"});
  
  print(response.body);
  
  }
  
  @override
  Widget build(BuildContext context) {
  return new Scaffold(
      body: new Center(
          child: new RaisedButton(
            child: new Text('Make Request'),
            onPressed: makeRequest,
          )));
  }
  }
  </code></pre>
  
  <p>Can someone please let me know how to get past this error?</p>
  
  <p>the error that I am facing is this.</p>
  
  <p>I/flutter ( 5881): Unsupported Media Type</p>
  
  <p><a href="https://i.stack.imgur.com/3AOqD.png" rel="noreferrer">Screenshot of Response Headers/Status Code/Body</a></p>
  
  <p><a href="https://i.stack.imgur.com/t2z4I.png" rel="noreferrer"><img src="https://i.stack.imgur.com/t2z4I.png" alt="enter image description here"></a></p>
  
  <p>Sorry for the messy code, it didn't copy paste over every well.</p>