Can anyone explain me how can I retrieve data from API https://185.86.145.54/cameras/all I tried to parse as http, didn't work. Every time I got this issue HandshakeException (HandshakeException: Handshake error in client (OS Error: CERTIFICATE_VERIFY_FAILED: self signed certificate(handshake.cc:354))) I tried use HttpClient and I could get API body, but I don't know how can I show values of API parameters in application.
3 Answers
You can use this online tool https://app.quicktype.io/ to generate your Dart Model Classes you will use to get api parameters in your application, simply paste the json response from your api. The approach is to make a model out of your api response
For the Handshake error, see this post stackoverflow

- 57
- 4
-
Yes, I tried use it, but I don't understand how exactly should I use it. Can you explain, please? – Pation Apr 27 '21 at 09:16
General thumb rule: If the server (API) is based on https (TLS) then the client should connect using https. If the server uses http (non-TLS) then the client should use http to connect to it.
Certificate verification is part of a process named HandShaking
which is the first step in a TLS (HTTPS) based communication.
In your case, the API you are trying to hit is an https ( https://185.86.145.54/cameras/all
) type but it seems that your using Uri.http()
to do the connection which will not provide any client side certification as it is non-TLS (http) resulting in your runtime exception.
Hence to fix your current problem from your flutter app you should use:
Uri uri = Uri.https("185.86.145.54/cameras/all");
http.get(uri); //http is from the import 'package:http/http.dart' as http;

- 4,584
- 4
- 26
- 37
-
Thank you for the answer, but what is baseUrl, endPointUrl in my case ? – Pation Apr 27 '21 at 09:18
-
-
-
@Pation Updated for your need but I think you need to read more about the `URI` class and the `http` package – Sisir Apr 27 '21 at 10:07
-
You need to get the data in an asynchronous function with a Future type and then use a FutureBuilder widget to display the data. I've also linked an article about building an RSS Feed in flutter, that helped me to understand how to get data from the web.
https://medium.com/@scottingram.scott/hacker-news-rss-app-in-flutter-976728b09361

- 193
- 11