0

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 3

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I tried use it, but I don't understand how exactly should I use it. Can you explain, please?
1

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;

5 Comments

Thank you for the answer, but what is baseUrl, endPointUrl in my case ?
Updated the answer to your need.
Can you write get function for my case, please?
@Pation Updated for your need but I think you need to read more about the URI class and the http package
I get new issue check image here ibb.co/zRCH12x
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.