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;
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.
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
add a comment |
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.
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
add a comment |
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.
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
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.
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
json dart flutter
asked Mar 25 at 5:38
codeinprogresscodeinprogress
65221331
65221331
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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"
);
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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"
);
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
add a comment |
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"
);
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
add a comment |
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"
);
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"
);
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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