Send HTTP GET Request using Java 11 HttpClient and parse JSON response into objects

  Рет қаралды 65,835

Dan Vega

Dan Vega

Күн бұрын

Пікірлер: 72
@nakuldighe8638
@nakuldighe8638 4 жыл бұрын
I almost thought it is impossible to learn http requests in java from the internet until i saw this video, thanx man. Great video by the way
@DanVega
@DanVega 4 жыл бұрын
Wow, that is so awesome of you to say. Thank you for watching.
@raymondkosos
@raymondkosos 3 жыл бұрын
Nice! Lot's of API's out there with data returned in JSON format - this tutorial is exactly what I needed to get started! Learning about the .forEach was also a bit of a bonus. I think all I need to do is find this done asynchronously and I'm all set ...
@DanVega
@DanVega 3 жыл бұрын
Glad it helped!
@pablohernandez4305
@pablohernandez4305 3 жыл бұрын
You saved my life, thank you for this video i had about two days with this topic and it was so easy.
@rogeriosartori5644
@rogeriosartori5644 4 жыл бұрын
Thanks man. Great tutorial! Simple and easy to understand. The best tutorial of http request in the internet.
4 жыл бұрын
I used to hate Java, but you just did make I love it.
@nurba_nurba
@nurba_nurba 4 жыл бұрын
video starts from 6:03. thank me later
@shwetaadurkar562
@shwetaadurkar562 2 жыл бұрын
Thank you!!..you made it simple and easy to understand.
@DanVega
@DanVega 2 жыл бұрын
Glad it helped!
@praveens2272
@praveens2272 Жыл бұрын
Is it possible to map the response with body handler itself ?
@laponiec
@laponiec 2 жыл бұрын
Is it possible to set multiple headers in our GET/POST method? In my program I need to set the authorization header (basicAuth), and I wonder if I can also set the content type.
@Armanhannani
@Armanhannani Ай бұрын
How can I return only one part of json string ?
@QwinTube
@QwinTube 3 жыл бұрын
Its great! Thanks very much!!! Please do more....
@kostiantynkarzhanov9216
@kostiantynkarzhanov9216 9 ай бұрын
Great tutorial! Thank you so much! 💛
@mcbondgh
@mcbondgh 10 күн бұрын
Clean and clear Sir
@samehyoussef4988
@samehyoussef4988 3 жыл бұрын
how to add password and username for authentication?
@pajeetsingh
@pajeetsingh 2 жыл бұрын
Do you think adding application related functionality directly into a programming language somehow defeat incentive to learn the language itself?
@DanVega
@DanVega 2 жыл бұрын
Not at all. Having to write low level code to interact with Http doesn't sound like fun to me. Program languages give us the ability to perform common tasks and I think this is a great abstraction here.
@devinbaack3578
@devinbaack3578 3 жыл бұрын
How would this work for nested Json?
@_kishorroy
@_kishorroy 2 жыл бұрын
This video helped me a lot in my learning phase. Thanks.
@alpanajyoti7774
@alpanajyoti7774 3 жыл бұрын
How one can use interceptor to maintain session cookies for okHttpclient with core Java?
@batesinheritance
@batesinheritance 2 жыл бұрын
Thank you very much. You helped me understand HttpClient Get() method.
@7thwik
@7thwik 3 жыл бұрын
Can someone explain on how to unit test these requests, responses using mockito ?
@grrlgd3835
@grrlgd3835 3 жыл бұрын
Tks Dan , very useful. how about to get an image ?
@zorfrak
@zorfrak 3 жыл бұрын
I'm able to retrieve the data from the API, but but I get IllegalStateException("Cipher not initialized"). Can I prevent this?
@cypherliquid
@cypherliquid Жыл бұрын
what if we want to send a jwt token.
@vanshrana9508
@vanshrana9508 2 жыл бұрын
It was very helpful, thanks a lot :)
@DanVega
@DanVega 2 жыл бұрын
You're welcome!
@michaelnewman2993
@michaelnewman2993 3 жыл бұрын
This may be a dumb question, but what if you only need to access a few specific fields of your Json object? For instance if I was using a geocoding api and only needed to return the latitude and longitude. Thanks for the video extremely helpful!
@conradpeterson1387
@conradpeterson1387 3 жыл бұрын
You've probably already figured this out, but you can just add the annotation "@JsonIgnoreProperties(ignoreUnknown=true)" to the object class and then you only have to include variables in the class for the specific fields you want.
@wiliamferraciolli5380
@wiliamferraciolli5380 3 жыл бұрын
Can you show us how to unit test it please? with mockito
@nidhishah9701
@nidhishah9701 3 жыл бұрын
how can we achieve this with localhost?
@kriszteblade
@kriszteblade Жыл бұрын
Perfect tutorial.
@iVarLitap
@iVarLitap 4 жыл бұрын
If i want to consume this web service then how can get object reference of Post class
@ArunKumar-oi1yu
@ArunKumar-oi1yu 2 жыл бұрын
I am getting exception when i invoke this "PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)"
@marlegagaming1274
@marlegagaming1274 3 жыл бұрын
I'm getting this error, could you please help me out readValue(JsonParser, Class) in the type ObjectMapper is not applicable for the arguments (Object, new TypeReference(){})
@marlegagaming1274
@marlegagaming1274 3 жыл бұрын
Never mind, fixed it, programming in a nut shell🤣 One second : no idea what's going on After making minor changes : I'm the best 🤣😉 Thanks for the great video.
@hariprasadbs966
@hariprasadbs966 4 жыл бұрын
I need this option in single java class file without any server like tomcat,glassfish or others When I try in single java class, I says error: No classdef error HTTPurirequest not found How to fix this
@FellTheSky
@FellTheSky 4 жыл бұрын
I need to send first an authentication request to get SESSION ID cookie and then make another request to get the data. Do you have a video about this, or know where i can read it? Im having a hard time finding material
@alpanajyoti7774
@alpanajyoti7774 3 жыл бұрын
did you get solution of above query? I have same problem, let me know , If you got solution.
@FellTheSky
@FellTheSky 3 жыл бұрын
@@alpanajyoti7774 String cookie = response.headers().firstValue("Set-Cookie").toString(); String cCookie = cookie.replaceAll(".+\\[", ""); String cleanCookie = cCookie.split(";")[0]; System.out.println(cleanCookie) Then on the second request: .setHeader("Cookie",cleanCookie)
@Hector21211
@Hector21211 3 жыл бұрын
excelente tutorial saludos desde argentina
@amirbeheshtian8426
@amirbeheshtian8426 3 жыл бұрын
Great toturial man thanks. Could you please make a toturial for Post method ? specially for this scenario : - Post a Json object ( which include user and pass) - get the value for token in response body.
@srinivasmurthy3386
@srinivasmurthy3386 3 жыл бұрын
Nice!. Thanks for the g8 video.
@DanVega
@DanVega 3 жыл бұрын
Thanks for watching!
@nikhilbansal196
@nikhilbansal196 4 жыл бұрын
Thanks for the information. I have a question : how can we send a get request with parameters using HttpClient in java 11?
@lieutenantflogy6183
@lieutenantflogy6183 4 жыл бұрын
I am curious about this as well. I've been looking for an answer and have yet to find one.
@abigailedwards1238
@abigailedwards1238 Жыл бұрын
Thanky ou this is exactly what i needed
@DanVega
@DanVega Жыл бұрын
Glad I could help out, let me know if you have any other questions about clients in Java
@Pritam252
@Pritam252 3 жыл бұрын
Why my one says GET() is undefined?
@DanVega
@DanVega 3 жыл бұрын
Do you have the correct imports? docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpRequest.Builder.html
@edwinkipruto7125
@edwinkipruto7125 3 жыл бұрын
that was very easy to understand, would you kindly make a video in consuming rest services using authentications , and web tokens
@ritiksoni8487
@ritiksoni8487 9 ай бұрын
what was that intro ?
@DanVega
@DanVega 8 ай бұрын
It was an old intro I had made. I don't use it anymore though
@alexandroskourtis5268
@alexandroskourtis5268 4 жыл бұрын
awesome tutorial :)
@haydn.murray
@haydn.murray 4 жыл бұрын
Hey Dan - great tutorial!! - What would you recommend when your JSON is a map....ie `{"someData": [{a: 1, b: 2}]}` and all I want is the "someData" value. Map posts = mapper .readValue(response.body(), new TypeReference() {}); posts.get("someData") //
@20M_Target_1.0
@20M_Target_1.0 2 жыл бұрын
How to login to Salesforce using Java 11 httpclient How get auth token and instanceUrl??
@Артур-з6щ7э
@Артур-з6щ7э 3 жыл бұрын
very cool, thanks!
@DanVega
@DanVega 3 жыл бұрын
No problem!
@stanislavivanov9817
@stanislavivanov9817 4 жыл бұрын
Thank you for this tutorial.
@DanVega
@DanVega 4 жыл бұрын
Thanks for watching 😊
@MegaMoses91
@MegaMoses91 4 жыл бұрын
Great Tutorial!
@andrii5866
@andrii5866 4 жыл бұрын
Thanks man. Great tutorial! Have you ever thought about a new video about Spring boot + GraphQl or Spring boot + GraphQl + security? I think it's a great topic for 2020.
@DanVega
@DanVega 4 жыл бұрын
Thank you. I have really been enjoying using GraphQL on my personal site this past year. Yes, Spring Boot + GraphQL is on my list.
@jafd7806
@jafd7806 4 жыл бұрын
Good content Bro 👌
@TTYounga
@TTYounga 4 жыл бұрын
Thank you so much!
@ruhnet
@ruhnet 4 жыл бұрын
Fantastic video! Thanks so much for taking the time to share it. I'm not fluent in Java but your video was still understandable and useful! One thing though, for future reference, the proper pronunciation of JSON is "jaysun", rather than "jay-sawn". 😀
@arkanglegeibriel
@arkanglegeibriel 3 жыл бұрын
"There's a lot of argument about how you pronounce that. I strictly don't care. I think the proper pronunciation is probably..." and then the guy uses a strange french-sounding pronunciation. So who said this? Well that'd be Douglas Crockford, the guy who invented the format. He says it like you do "jaysun". And I know this comment is old, but it's one of the top of this video so I'ma just... correct that number and that statement and move on, have a nice day ^_^
@30sana
@30sana 3 жыл бұрын
Honestly after all that ima just consider learning python to use requests easier wtf xD
@japanboy31415
@japanboy31415 2 жыл бұрын
@7:30
How to call a Java REST API using JDK Http Client
22:23
Dan Vega
Рет қаралды 10 М.
How To Call a REST API In Java - Simple Tutorial
29:14
Coding with John
Рет қаралды 288 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
How to Send HTTP Request and Parse JSON Data Using Java
27:22
Coding Master - Programming Tutorials
Рет қаралды 202 М.
"Spring Boot REST Client Logging Made Easy
22:25
Dan Vega
Рет қаралды 5 М.
How to send a GET request and fetch a response as a JAVA OBJECT?
12:20
if else statement
Рет қаралды 11 М.
use Apache HttpClient to consume web services
23:41
Cottrell Coding
Рет қаралды 7 М.
#15 Spring Web Http methods GET and POST
20:55
Telusko
Рет қаралды 37 М.
HTTP Client - Secret Weapon for Web Service Testing
57:23
IntelliJ IDEA, a JetBrains IDE
Рет қаралды 32 М.
Parse JSON using Java
22:27
Coding Simplified
Рет қаралды 7 М.