Spring Boot call REST API Tutorial

Sdílet
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 ❤️

Komentáře • 62

  • @Daniel-Murphy951
    @Daniel-Murphy951 Před 6 měsíci +1

    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!

  • @kaatlev
    @kaatlev Před 2 lety +5

    love the real world examples these are so helpful

    • @DanVega
      @DanVega  Před 2 lety

      Thank you so much. Glad these videos are helping 🤩

  • @ds866
    @ds866 Před rokem +1

    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 😇😇

  • @andyl.5998
    @andyl.5998 Před rokem +2

    It'd really great to have a tutorial on jackson, as mentioned at 11:25.

  • @tohidfla
    @tohidfla Před 2 lety +3

    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

  • @derda1304
    @derda1304 Před rokem

    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)

  • @nicolasbriand9114
    @nicolasbriand9114 Před rokem +2

    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 ?

    • @DanVega
      @DanVega  Před rokem +2

      I'm in a MVC application which is blocking so RestTemplate works fine. If you're in reactive application I would reach for WebClient.

  • @koushiksinha4822
    @koushiksinha4822 Před 2 lety +2

    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 :)

    • @DanVega
      @DanVega  Před 2 lety +1

      Sounds like a great suggestion. I will see if I can find a good public API that needs auth to use.

  • @priteshsingh299
    @priteshsingh299 Před rokem +1

    Love from Nepal.

    • @DanVega
      @DanVega  Před rokem +1

      Thank you for the support in Nepal. 🙏

  • @paulfx5019
    @paulfx5019 Před rokem

    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?

  • @alessandrodemanzano3527
    @alessandrodemanzano3527 Před 2 lety +2

    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!

    • @DanVega
      @DanVega  Před rokem +2

      I honestly haven't done work with SOAP in years. Sorry 🤦‍♂️

    • @alessandrodemanzano3527
      @alessandrodemanzano3527 Před rokem +1

      @@DanVega hehe, unfortunately some State-based service here in Italy still use it.. thanks anyway!

  • @ruslansimakov9087
    @ruslansimakov9087 Před 2 lety +2

    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?

    • @DanVega
      @DanVega  Před rokem +1

      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.

  • @murunatan6661
    @murunatan6661 Před 2 lety +2

    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.

    • @DanVega
      @DanVega  Před 2 lety +2

      What errors are you getting? I don't change any dialect for the h2 embedded db.

    • @murunatan6661
      @murunatan6661 Před 2 lety +1

      @@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.

  • @manojpal8337
    @manojpal8337 Před 4 měsíci

    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 ?

  • @jeevanthalluri2200
    @jeevanthalluri2200 Před 2 lety +1

    Please upload one e commerce project with dashboard with springboot security jdbc + react hooks

  •  Před 2 lety +1

    As usual Dan, superb work! Just the question that follows, how to deal with token authentication to service and chaching, alternatives Thanks!!!

    • @DanVega
      @DanVega  Před 2 lety +2

      I have a video on using JWTs for authentication. What exactly are you looking to do so I can be sure of your question.

    •  Před 2 lety

      @@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!!!

  • @mrooglyboogie4118
    @mrooglyboogie4118 Před rokem

    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?

  • @victorbear4904
    @victorbear4904 Před rokem

    Hi Dan , could you please make some videos about spring cloud and micro services,thanks

  • @leong5940
    @leong5940 Před 7 měsíci

    can you show how to get response body when api don't return 200 status?

  • @seyhaphan7319
    @seyhaphan7319 Před rokem

    Very useful, Thanks a lot. Dan, how about spring framework 6: http inteface in production

  • @Marnee4191
    @Marnee4191 Před rokem +1

    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.

    • @SaifulIslam-fo1bt
      @SaifulIslam-fo1bt Před 10 měsíci +1

      Everyone not pro like you bro..

    • @Marnee4191
      @Marnee4191 Před 10 měsíci

      @@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.

  • @nurhadi-dev
    @nurhadi-dev Před 2 lety

    thank you sir. as always,, great content n very useful.

  • @marciosantos941
    @marciosantos941 Před rokem

    Excelent content! Thank you so much.

  • @rdothl5
    @rdothl5 Před rokem

    You the man, thanks for this.

  • @ashishsengar87
    @ashishsengar87 Před 2 lety +1

    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.

    • @DanVega
      @DanVega  Před 2 lety

      What exceptions are being thrown?

  • @alexbrun6863
    @alexbrun6863 Před rokem

    nice tutorial subscribed :)

  • @amritadhikari1188
    @amritadhikari1188 Před rokem

    Awesome

  • @abdulrhmanbashammakh7006

    Thanks

  • @Lauchilus
    @Lauchilus Před rokem

    great content!!

  • @djgavrilove
    @djgavrilove Před 2 lety +1

    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.)

    • @ruslansimakov9087
      @ruslansimakov9087 Před 2 lety +2

      As of Spring Framework 5, alongside the WebFlux stack, Spring introduced a new HTTP client called WebClient. RestTemplate would be deprecated

    • @djgavrilove
      @djgavrilove Před 2 lety

      @@ruslansimakov9087 thanks

    • @DanVega
      @DanVega  Před rokem +4

      That's not true. RestTemplate is feature complete, not deprecated. I still reach for RestTemplate in my Spring MVC applications.

    • @DanVega
      @DanVega  Před rokem +4

      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.

    • @djgavrilove
      @djgavrilove Před rokem

      @@DanVega thanks

  • @OmarMendozaKS
    @OmarMendozaKS Před rokem

    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)?

    • @DanVega
      @DanVega  Před rokem +1

      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.

    • @OmarMendozaKS
      @OmarMendozaKS Před rokem

      @@DanVega thanks for reading

  • @dekeyserwilly
    @dekeyserwilly Před 2 lety

    Great 👍👍

  • @kay2care
    @kay2care Před 2 lety

  • @jopadjr
    @jopadjr Před 2 lety

    33rd...Thanks Dan

  • @ConvierteteAJesúsAhora
    @ConvierteteAJesúsAhora Před rokem +1

    If you were pronouncing more clearly for non-natives as me :(

    • @DanVega
      @DanVega  Před rokem +1

      I'm sorry I thought I was pretty clear. I will make an effort to do better in the next video.

  • @user-vc1yc6ne9j
    @user-vc1yc6ne9j Před rokem

    very confusing video

  • @gordanainic2766
    @gordanainic2766 Před rokem +1

    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!

    • @DanVega
      @DanVega  Před rokem +1

      Did you add it as an argument to the commandLineRunner method?