Register post request is failing on flutter app production

1,837 views
Skip to first unread message

CYRIL P. JOY

unread,
Aug 11, 2019, 9:05:19 AM8/11/19
to Flutter Development (flutter-dev)
I am facing an issue with http post request  for register in my flutter app. 


    http.Response response = await http.post(
        body: {"username": _username, "email": _email, "password": _password});
    final responseData = json.decode(response.body);
when this post request is executed,  i am getting error as,
[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FormatException: Unexpected character (at character 1)E/flutter (25820): <!DOCTYPE html>
E/flutter (25820): ^
E/flutter (25820):

I deployed my app to Heroku  and  tried with the new url, i am getting the same error  with heroku url also.


I tried  the above post command on Postman also, the response is   provided below

<!DOCTYPE html>
<html>
  <head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>Application Error</title>
<style media="screen">
  html,body,iframe {
margin: 0;
padding: 0;
}
  html,body {
height: 100%;
overflow: hidden;
}
  iframe {
width: 100%;
height: 100%;
border: 0;
}
</style>
  </head>
  <body>
  </body>
</html>
please find the images  below for  postman  settings page, and result obtained.


Only register request is having the issue, login post request is working fine.
        body: {"identifier": _email, "password": _password});
        print('LOGIN body: [${response.body}]');
    final responseData = json.decode(response.body);
The above post request is working fine from app and through Postman.      Kindly help,  i dont have any clue why register is not working.
response.PNG
Strapi.PNG

CYRIL P. JOY

unread,
Aug 11, 2019, 9:06:47 AM8/11/19
to Flutter Development (flutter-dev)
Please find the below picture, strapi picture uploaded  accidently.
body.PNG

Andy Greenshaw

unread,
Aug 11, 2019, 9:07:16 AM8/11/19
to Flutter Development (flutter-dev), CYRIL P. JOY
Your 1st post is not returning JSON, so the decode fails.
--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/b85a855e-8411-4a33-8e2c-66ec9658fe45%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages