'Flutter api post request error with golang api working with in postman but not flutter
src="//www.herokucdn.com/error-pages/application-error.html"></iframe>
I/flutter (10634): </body>
I/flutter (10634): </html>
My problem is in making a post request to my golang api it is working fine in postman but not in flutter it giving some error like this could anyone help me with this
Solution 1:[1]
We need more information to detect your problem.
- Can you share the code how to handle your API requests?
- Which HTTP Client have used? ( http, Chopper, dio etc. )
Sometimes Flutter throws Handsake errors like CERTIFICATE_VERIFY_FAILED etc. Maybe you should try to override the default HttpOverrides class.
/// Override the badCertificateCallback to always true.
class NewHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext? context) {
return super.createHttpClient(context)
..badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
}
}
...
/// Change the global HttpOverrides before runApp.
void main(){
HttpOverrides.global = NewHttpOverrides();
runApp(const MyApp());
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Balint Takacs |
