title: http post request doesn't work for my flutter app code
body: <p>I'm trying to do an HTTP post request to the postman URL. In code, I can't find any error but it doesn't work in the flutter app.</p>
  <p>though the data is entered in the text box, the response is not showing in a flutter. i have attached the image</p>
  <p><a href="https://i.stack.imgur.com/X6xEO.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p><strong>Request body in postman code attached.</strong></p>
  <p><strong>This is the response body in postman:</strong>
  {<a href="https://i.stack.imgur.com/HxTzM.png" rel="nofollow noreferrer">enter image description here</a>
  &quot;processingTime&quot;: 1,
  &quot;result&quot;: {
  &quot;id&quot;: &quot;fa6a14d5-2888-4634-8158-efcaa0690211&quot;,
  &quot;noteType&quot;: &quot;PRIVATE_NOTE&quot;,
  &quot;privacy&quot;: &quot;PRIVATE&quot;,
  &quot;reaction&quot;: &quot;NEUTRAL&quot;,
  &quot;description&quot;: &quot;KUSHAN  1&quot;,
  &quot;status&quot;: &quot;ACTIVE&quot;,
  &quot;author&quot;: &quot;Test User&quot;,
  &quot;authorId&quot;: &quot;00000000-0000-0000-0000-000000000000&quot;,
  &quot;modified&quot;: &quot;2021-09-07T13:59:33.9926797Z&quot;,
  &quot;flagged&quot;: false
  }
  }</p>
  <p><strong>This is my code:</strong></p>
  <pre><code>import 'dart:ui';
  import 'package:flutter/material.dart';
  import 'package:http/http.dart' as http;
  
  postData() async {
    try {
      var response = await http.post(
          Uri.parse(&quot;https://zen-api-1010.azure-api.net/notes/v1/create&quot;),
          headers: {
            &quot;Ocp-Apim-Subscription-Key&quot;: &quot;008c47b597e54aedadbd5e4d270b35ed&quot;,
            &quot;Ocp-Apim-Trace&quot;: &quot;true&quot;
          },
          body: {
            &quot;noteType&quot;: 0.toString(),
            &quot;description&quot;: &quot;KUSHAN  1&quot;.toString(),
            &quot;authorReaction&quot;: 0.toString(),
            &quot;privacy&quot;: 0.toString(),
          });
      print(response.body);
    } catch (e) {
      print(e);
    }
  }
  
  class NavPrivatePage extends StatefulWidget {
    @override
    _NavPrivatePageState createState() =&gt; _NavPrivatePageState();
  }
  
  class _NavPrivatePageState extends State&lt;NavPrivatePage&gt; {
    TextEditingController noteTypeController = TextEditingController();
    TextEditingController descriptionController = TextEditingController();
    TextEditingController authorReactionController = TextEditingController();
    TextEditingController privacyController = TextEditingController();
  
    bool inVisible = true;
    bool isNotVisible = false;
  
    @override
    Widget build(BuildContext context) =&gt; Scaffold(
          appBar: AppBar(
            title: Text(
              'Private Note Auto Expand',
              style: TextStyle(
                fontSize: 14,
              ),
            ),
            centerTitle: true,
            backgroundColor: const Color.fromRGBO(255, 191, 0, 1),
          ),
          body: SingleChildScrollView(
            child: Center(
              child: Padding(
                padding: const EdgeInsets.all(10.0),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: [
                    Visibility(
                      visible: inVisible,
                      child: TextButton(
                        onPressed: () {
                          setState(() {
                            isNotVisible = !isNotVisible;
                          });
                        },
                        child: Text(
                          'Create Private Note',
                          style: TextStyle(
                            color: Colors.white,
                          ),
                        ),
                        style: TextButton.styleFrom(
                          backgroundColor: Colors.grey[900],
                        ),
                      ),
                    ),
                    Visibility(
                      visible: isNotVisible,
                      child: Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: TextFormField(
                          controller: descriptionController,
                          autofocus: false,
                          onChanged: (text) {
                            print(&quot;Text $text&quot;);
                          },
                          minLines: 2,
                          maxLines: 20,
                          keyboardType: TextInputType.multiline,
                          decoration: InputDecoration(
                            hintText: 'Enter your message here',
                            hintStyle: TextStyle(
                              color: Colors.grey[600],
                              fontSize: 12,
                            ),
                            border: OutlineInputBorder(
                              borderRadius: BorderRadius.all(Radius.circular(5)),
                            ),
                          ),
                        ),
                      ),
                    ),
                    Visibility(
                      visible: isNotVisible,
                      child: TextButton(
                        onPressed: () {
                          postData();
                        },
                        child: Text(
                          'Submit',
                          style: TextStyle(
                            color: Colors.white,
                          ),
                        ),
                        style: TextButton.styleFrom(
                          backgroundColor: Colors.grey[600],
                        ),
                      ),
                    ),
                    Visibility(
                      visible: isNotVisible,
                      child: Center(
                        child: Card(
                          shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(10)),
                          color: Colors.grey[300],
                          child: Container(
                            padding: EdgeInsets.all(10),
                            height: 130,
                            child: Column(
                              mainAxisSize: MainAxisSize.min,
                              children: [
                                ListTile(
                                  trailing: Icon(Icons.more_horiz),
                                  leading: CircleAvatar(
                                    backgroundImage: NetworkImage(
                                        'https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg?auto=compress&amp;cs=tinysrgb&amp;dpr=1&amp;w=500'),
                                  ),
                                  subtitle: Text(
                                    '2 days ago',
                                    style: TextStyle(
                                      color: Colors.grey[800],
                                    ),
                                  ),
                                ),
                                Text(
                                    'This is a private note that auto expands based on the text entered. The background will determine the privacy level of the post',
                                    style: TextStyle(
                                      fontSize: 10,
                                      color: Colors.black87,
                                    ),
                                    textAlign: TextAlign.justify),
                              ],
                            ),
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
        );
  }
  </code></pre>