Spring Boot call REST API Tutorial
Vložit
- čas přidán 7. 09. 2024
- In this tutorial, you will learn how to call a REST API in Spring Boot using the REST template. This is a good way to make a request to a public API or to another microservice in your distributed architecture.
🔗Resources & Links mentioned in this video:
Github Repo: github.com/dan...
Spring Data JDBC - How to use custom ID generation: spring.io/blog...
👋🏻Connect with me:
Website: www.danvega.dev
Twitter: / therealdanvega
Github: github.com/dan...
LinkedIn: / danvega
Newsletter: www.danvega/de...
SUBSCRIBE TO MY CHANNEL: bit.ly/2re4GH0 ❤️
Dude legit saved my career! Wish they taught us this stuff in college lol! Though you gotta be on top your game lol. He goes fast!
love the real world examples these are so helpful
Thank you so much. Glad these videos are helping 🤩
Thank you so much Dan, for creating a video based on my question to you, hopefully it can be help someone else who feel the same situation 😇😇
Thank you!
It'd really great to have a tutorial on jackson, as mentioned at 11:25.
Great content. as another sequence video can you please add a queue to this two service so one can put todos in queue and other one picking it up whenever ready. that would be a good idea
Thank you for your work
great tutorial, still works in Spring Boot 3
greetings from Vienna :D thanks for this lecture :D
if you want a suggestion for a new video: Security in SpringBoot3 doesn't have much educational content online right now (well haven't looked really thoroughly right now, but i will need it in the future)
Hi, thank you for the time and the content, as the content is pretty recent, is there a reason you did not use WebClient over RestTemplate ?
I'm in a MVC application which is blocking so RestTemplate works fine. If you're in reactive application I would reach for WebClient.
Would be great if you create a video on consuming 3rd party API with live authentication using webclient, and explain little bit under the hood concept..like the jackson one you mentioned....Cheers :)
Sounds like a great suggestion. I will see if I can find a good public API that needs auth to use.
Love from Nepal.
Thank you for the support in Nepal. 🙏
Great tutorial. What be more real word like is to add security dependency to both services, with the Dashboard service using form base security and API using token base security and finally Todo service using token base security only. Maybe a part 2 tutorial?
very interesting, thanks ! What about a video about the old-but-still-used-sigh SOAP services ? maybe something about creating both server and client SOAP services starting from WSDL and XSD provided files.. ;-) thanks anyway!
I honestly haven't done work with SOAP in years. Sorry 🤦♂️
@@DanVega hehe, unfortunately some State-based service here in Italy still use it.. thanks anyway!
Copypasting Model-class to each services produce inconsistency (one place we changing, for another place - we forgetting).
What is the best way to avoid DRY?
In a distributed architecture you are going to have some duplicated code and it's just part of the trade-off. A lot of the time it isn't a straight copy where a Model might be represented one way in service A and another in service B. When I think of DRY I think about it in the same system, not 2 different systems.
Excellent one. Just one suggestion regarding the H2 DB please suggest the Dialect or mode. Beginners will stuck if that part is giving Runtime errors.
What errors are you getting? I don't change any dialect for the h2 embedded db.
@@DanVega Yes, you are correct, in mem h2 db it works fine. It is my bad I had a local h2 with a different dialect caused an issue for me. False flag sorry.
Hello , Thank you for the Explanation , Please keep continuing the same , Love the way you code. I am getting 401 Unauthorised: [no body] Error while calling external rest points. Do you have any suggestion ?
Please upload one e commerce project with dashboard with springboot security jdbc + react hooks
As usual Dan, superb work! Just the question that follows, how to deal with token authentication to service and chaching, alternatives Thanks!!!
I have a video on using JWTs for authentication. What exactly are you looking to do so I can be sure of your question.
@@DanVega I am looking for Bearer Authentication, how to add the token in the header of the request. I am looking also about the way to filter and map a complex json collection. Thank you Dan!!!
Hello, I am trying to call a third-party API, but it requires authentication (bearer token) to get the data, how do I proceed from what you showed in this video?
Hi Dan , could you please make some videos about spring cloud and micro services,thanks
can you show how to get response body when api don't return 200 status?
Very useful, Thanks a lot. Dan, how about spring framework 6: http inteface in production
I really appreciate your videos. I have some suggestions to make them easier to consume. First, please make your audio louder. It's always too quiet. Also, please don't start from scratch in every video. Prepare the services and DB records in advance. We don't need to see that every time.
Everyone not pro like you bro..
@@SaifulIslam-fo1bt That has nothing to do with it. There should be one video with the basics of creating a non-production Spring Boot app, which he could link to in each of his other videos. He doesn't need to repeat that in every single video, making them longer than they need to be and making it more difficult to know when the actual tutorial starts.
thank you sir. as always,, great content n very useful.
Excelent content! Thank you so much.
You the man, thanks for this.
In app I am using the rest template to post and get but rest template throws exception when status is not 200. So the line for checking status does not get executed.
What exceptions are being thrown?
nice tutorial subscribed :)
Awesome
Thanks
great content!!
Very useful, thanks a lot. Dan, one more things to clarify: in order to avoid hard coded binding directly to localhost:8080 and localhost:8081 should we use Open feign Client, am I correct ? Are there other alternatives? How often in production is RestTemplate used? Thanks again.)
As of Spring Framework 5, alongside the WebFlux stack, Spring introduced a new HTTP client called WebClient. RestTemplate would be deprecated
@@ruslansimakov9087 thanks
That's not true. RestTemplate is feature complete, not deprecated. I still reach for RestTemplate in my Spring MVC applications.
You are correct that you don't want to hard code URLs + ports because those can change. In a distributed architecture you would use something like service discovery and avoid hard coding URLs.
@@DanVega thanks
Hi Dan, thanks for all the help you provide, always clear and helpful, is it possible for you to shed some light on what free alternatives to Heroku hosting you recommend (java deploy, JIC)?
I'm working on putting this list together now... I don't know if you're going to find a lot of free options but railway.app has a great free tier for at least getting something started.
@@DanVega thanks for reading
Great 👍👍
33rd...Thanks Dan
If you were pronouncing more clearly for non-natives as me :(
I'm sorry I thought I was pretty clear. I will make an effort to do better in the next video.
very confusing video
Thank you so mach for so great! I I get little issue . In the Method commandLinkeRunner i have problem that TodoServiceApplication required a bean of type 'dev.goca.todoservice.repository.ToDoRepository' that could not be found. Can sambedy please help with that?... Thank you so mach!
Did you add it as an argument to the commandLineRunner method?