Flutter: Send JSON body for Http GET requestPost JSON using Python RequestsHow do I get ASP.NET Web API to return JSON instead of XML using Chrome?POST Request works with Postman, but not with GuzzleHow to send the output of a GET REST request as body of POST request using PostmanSwift login to json APIFlutter: HTTP get request body is emptyHTTP POST with Json on Body - Flutter/Dartcan't parse JSON from a post requestsis there away to ping heroku app from windows iam getting request time outHow to Http Post with Json Body on Flutter

What is the context for Napoleon's quote "[the Austrians] did not know the value of five minutes"?

Are there examples of rowers who also fought?

In the US, can a former president run again?

Am I legally required to provide a (GPL licensed) source code even after a project is abandoned?

How do I gain the trust of other PCs?

Movie: during a weekend in a house, a young kid befriends someone eating anything, they find the place of a plant scientist who reached immortality

Is using legacy mode instead of UEFI mode a bad thing to do?

Counterfeit check

Why things float in space, though there is always gravity of our star is present

Why do you need to heat the pan before heating the olive oil?

How to make all magic-casting innate, but still rare?

Are there any individual aliens that have gained superpowers in the Marvel universe?

How useful is the GRE Exam?

My student in one course asks for paid tutoring in another course. Appropriate?

Space-efficient algorithm for checking if strings with backspaces are equal?

How can I prevent a user from copying files on another hard drive?

Basic power tool set for Home repair and simple projects

In Street Fighter, what does the M stand for in M Bison?

King or Queen-Which piece is which?

How much steel armor can you wear and still be able to swim?

How to write a nice frame challenge?

Negation of a verb in the "passé Composé" and used with a "COI"

Bent arrow under a node

Kelvin type connection



Flutter: Send JSON body for Http GET request


Post JSON using Python RequestsHow do I get ASP.NET Web API to return JSON instead of XML using Chrome?POST Request works with Postman, but not with GuzzleHow to send the output of a GET REST request as body of POST request using PostmanSwift login to json APIFlutter: HTTP get request body is emptyHTTP POST with Json on Body - Flutter/Dartcan't parse JSON from a post requestsis there away to ping heroku app from windows iam getting request time outHow to Http Post with Json Body on Flutter






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I need to make a GET request to an API from my Flutter app which requires request body as JSON (raw).



I tested the API with JSON request body in Postman and it seems to be working fine.



enter image description here



Now on my Flutter application I am trying to do the same thing:



_fetchDoctorAvailability() async 
var params =
"doctor_id": "DOC000506",
"date_range": "25/03/2019-25/03/2019" ,
"clinic_id":"LAD000404"
;

Uri uri = Uri.parse("http://theapiiamcalling:8000");
uri.replace(queryParameters: params);

var response = await http.get(uri, headers:
"Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
HttpHeaders.contentTypeHeader: "application/json",
"callMethod" : "DOCTOR_AVAILABILITY"
);

print('---- status code: $response.statusCode');
var jsonData = json.decode(response.body);

print('---- slot: $jsonData');



However the API gives me an error saying




message: Missing input json., status: false




How do I send a raw (or rather JSON) request body for Http GET request in Flutter?










share|improve this question




























    2















    I need to make a GET request to an API from my Flutter app which requires request body as JSON (raw).



    I tested the API with JSON request body in Postman and it seems to be working fine.



    enter image description here



    Now on my Flutter application I am trying to do the same thing:



    _fetchDoctorAvailability() async 
    var params =
    "doctor_id": "DOC000506",
    "date_range": "25/03/2019-25/03/2019" ,
    "clinic_id":"LAD000404"
    ;

    Uri uri = Uri.parse("http://theapiiamcalling:8000");
    uri.replace(queryParameters: params);

    var response = await http.get(uri, headers:
    "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
    HttpHeaders.contentTypeHeader: "application/json",
    "callMethod" : "DOCTOR_AVAILABILITY"
    );

    print('---- status code: $response.statusCode');
    var jsonData = json.decode(response.body);

    print('---- slot: $jsonData');



    However the API gives me an error saying




    message: Missing input json., status: false




    How do I send a raw (or rather JSON) request body for Http GET request in Flutter?










    share|improve this question
























      2












      2








      2








      I need to make a GET request to an API from my Flutter app which requires request body as JSON (raw).



      I tested the API with JSON request body in Postman and it seems to be working fine.



      enter image description here



      Now on my Flutter application I am trying to do the same thing:



      _fetchDoctorAvailability() async 
      var params =
      "doctor_id": "DOC000506",
      "date_range": "25/03/2019-25/03/2019" ,
      "clinic_id":"LAD000404"
      ;

      Uri uri = Uri.parse("http://theapiiamcalling:8000");
      uri.replace(queryParameters: params);

      var response = await http.get(uri, headers:
      "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
      HttpHeaders.contentTypeHeader: "application/json",
      "callMethod" : "DOCTOR_AVAILABILITY"
      );

      print('---- status code: $response.statusCode');
      var jsonData = json.decode(response.body);

      print('---- slot: $jsonData');



      However the API gives me an error saying




      message: Missing input json., status: false




      How do I send a raw (or rather JSON) request body for Http GET request in Flutter?










      share|improve this question














      I need to make a GET request to an API from my Flutter app which requires request body as JSON (raw).



      I tested the API with JSON request body in Postman and it seems to be working fine.



      enter image description here



      Now on my Flutter application I am trying to do the same thing:



      _fetchDoctorAvailability() async 
      var params =
      "doctor_id": "DOC000506",
      "date_range": "25/03/2019-25/03/2019" ,
      "clinic_id":"LAD000404"
      ;

      Uri uri = Uri.parse("http://theapiiamcalling:8000");
      uri.replace(queryParameters: params);

      var response = await http.get(uri, headers:
      "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
      HttpHeaders.contentTypeHeader: "application/json",
      "callMethod" : "DOCTOR_AVAILABILITY"
      );

      print('---- status code: $response.statusCode');
      var jsonData = json.decode(response.body);

      print('---- slot: $jsonData');



      However the API gives me an error saying




      message: Missing input json., status: false




      How do I send a raw (or rather JSON) request body for Http GET request in Flutter?







      json dart flutter






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 5:38









      codeinprogresscodeinprogress

      65221331




      65221331






















          1 Answer
          1






          active

          oldest

          votes


















          1














          uri.replace... returns a new Uri, so you have to assign it into a new variable or use directly into the get function.



          final newURI = uri.replace(queryParameters: params);

          var response = await http.get(newURI, headers:
          "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
          HttpHeaders.contentTypeHeader: "application/json",
          "callMethod" : "DOCTOR_AVAILABILITY"
          );


          using post:



           var params = 
          "doctor_id": "DOC000506",
          "date_range": "25/03/2019-25/03/2019" ,
          "clinic_id":"LAD000404"
          ;

          var response = await http.post("http://theapiiamcalling:8000",
          body: json.encode(params)
          ,headers:
          "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
          HttpHeaders.contentTypeHeader: "application/json",
          "callMethod" : "DOCTOR_AVAILABILITY"
          );





          share|improve this answer

























          • Thanks, now I no longer get that error message but the response body comes back as empty.

            – codeinprogress
            Mar 25 at 6:01






          • 1





            maybe you should use post instead of get to send raw data.

            – diegoveloper
            Mar 25 at 6:04











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331782%2fflutter-send-json-body-for-http-get-request%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          uri.replace... returns a new Uri, so you have to assign it into a new variable or use directly into the get function.



          final newURI = uri.replace(queryParameters: params);

          var response = await http.get(newURI, headers:
          "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
          HttpHeaders.contentTypeHeader: "application/json",
          "callMethod" : "DOCTOR_AVAILABILITY"
          );


          using post:



           var params = 
          "doctor_id": "DOC000506",
          "date_range": "25/03/2019-25/03/2019" ,
          "clinic_id":"LAD000404"
          ;

          var response = await http.post("http://theapiiamcalling:8000",
          body: json.encode(params)
          ,headers:
          "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
          HttpHeaders.contentTypeHeader: "application/json",
          "callMethod" : "DOCTOR_AVAILABILITY"
          );





          share|improve this answer

























          • Thanks, now I no longer get that error message but the response body comes back as empty.

            – codeinprogress
            Mar 25 at 6:01






          • 1





            maybe you should use post instead of get to send raw data.

            – diegoveloper
            Mar 25 at 6:04















          1














          uri.replace... returns a new Uri, so you have to assign it into a new variable or use directly into the get function.



          final newURI = uri.replace(queryParameters: params);

          var response = await http.get(newURI, headers:
          "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
          HttpHeaders.contentTypeHeader: "application/json",
          "callMethod" : "DOCTOR_AVAILABILITY"
          );


          using post:



           var params = 
          "doctor_id": "DOC000506",
          "date_range": "25/03/2019-25/03/2019" ,
          "clinic_id":"LAD000404"
          ;

          var response = await http.post("http://theapiiamcalling:8000",
          body: json.encode(params)
          ,headers:
          "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
          HttpHeaders.contentTypeHeader: "application/json",
          "callMethod" : "DOCTOR_AVAILABILITY"
          );





          share|improve this answer

























          • Thanks, now I no longer get that error message but the response body comes back as empty.

            – codeinprogress
            Mar 25 at 6:01






          • 1





            maybe you should use post instead of get to send raw data.

            – diegoveloper
            Mar 25 at 6:04













          1












          1








          1







          uri.replace... returns a new Uri, so you have to assign it into a new variable or use directly into the get function.



          final newURI = uri.replace(queryParameters: params);

          var response = await http.get(newURI, headers:
          "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
          HttpHeaders.contentTypeHeader: "application/json",
          "callMethod" : "DOCTOR_AVAILABILITY"
          );


          using post:



           var params = 
          "doctor_id": "DOC000506",
          "date_range": "25/03/2019-25/03/2019" ,
          "clinic_id":"LAD000404"
          ;

          var response = await http.post("http://theapiiamcalling:8000",
          body: json.encode(params)
          ,headers:
          "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
          HttpHeaders.contentTypeHeader: "application/json",
          "callMethod" : "DOCTOR_AVAILABILITY"
          );





          share|improve this answer















          uri.replace... returns a new Uri, so you have to assign it into a new variable or use directly into the get function.



          final newURI = uri.replace(queryParameters: params);

          var response = await http.get(newURI, headers:
          "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
          HttpHeaders.contentTypeHeader: "application/json",
          "callMethod" : "DOCTOR_AVAILABILITY"
          );


          using post:



           var params = 
          "doctor_id": "DOC000506",
          "date_range": "25/03/2019-25/03/2019" ,
          "clinic_id":"LAD000404"
          ;

          var response = await http.post("http://theapiiamcalling:8000",
          body: json.encode(params)
          ,headers:
          "Authorization": Constants.APPOINTMENT_TEST_AUTHORIZATION_KEY,
          HttpHeaders.contentTypeHeader: "application/json",
          "callMethod" : "DOCTOR_AVAILABILITY"
          );






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 25 at 6:05

























          answered Mar 25 at 5:52









          diegoveloperdiegoveloper

          18.5k22839




          18.5k22839












          • Thanks, now I no longer get that error message but the response body comes back as empty.

            – codeinprogress
            Mar 25 at 6:01






          • 1





            maybe you should use post instead of get to send raw data.

            – diegoveloper
            Mar 25 at 6:04

















          • Thanks, now I no longer get that error message but the response body comes back as empty.

            – codeinprogress
            Mar 25 at 6:01






          • 1





            maybe you should use post instead of get to send raw data.

            – diegoveloper
            Mar 25 at 6:04
















          Thanks, now I no longer get that error message but the response body comes back as empty.

          – codeinprogress
          Mar 25 at 6:01





          Thanks, now I no longer get that error message but the response body comes back as empty.

          – codeinprogress
          Mar 25 at 6:01




          1




          1





          maybe you should use post instead of get to send raw data.

          – diegoveloper
          Mar 25 at 6:04





          maybe you should use post instead of get to send raw data.

          – diegoveloper
          Mar 25 at 6:04



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331782%2fflutter-send-json-body-for-http-get-request%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript