Simplest way to make HTTP request in Spring The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experiencemaximum length of HTTP GET request?What's the difference between @Component, @Repository & @Service annotations in Spring?Need help on RestTemplate Post Request with Body Parameters?Spring Android Get Request implementation : Could not extract response: no suitable HttpMessageConverter found for response type and content typeSpring 4.1.0 RestTemplate POST callHandle multipart/mixed response with Spring RestTemplateConsuming HAL-based REST service with spring-hateoasProper way to parse the body of an error with Spring's RestTemplatespring restTemplate dynamic mappingSpring RestTemplate + Basic Authentication + Post with request Body: 500 Internal Server Error

Sort list of array linked objects by keys and values

system call string length limit

verb not working in beamer even though I use [fragile]

What was the last x86 CPU that did not have the x87 floating-point unit built in?

Keeping a retro style to sci-fi spaceships?

Synthesis of a weinreb amide from an acid

Make it rain characters

When did F become S? Why?

Can undead you have reanimated wait inside a portable hole?

Can the DM override racial traits?

Do working physicists consider Newtonian mechanics to be "falsified"?

Does Parliament need to approve the new Brexit delay to 31 October 2019?

How is simplicity better than precision and clarity in prose?

How to grep and cut numbes from a file and sum them

Finding the path in a graph from A to B then back to A with a minimum of shared edges

Windows 10: How to Lock (not sleep) laptop on lid close?

How do you keep chess fun when your opponent constantly beats you?

What do you call a plan that's an alternative plan in case your initial plan fails?

Would an alien lifeform be able to achieve space travel if lacking in vision?

How to tell if two pearson correlations from the same sample differ significanly

How can I protect witches in combat who wear limited clothing?

A pet rabbit called Belle

Is there a writing software that you can sort scenes like slides in PowerPoint?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?



Simplest way to make HTTP request in Spring



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experiencemaximum length of HTTP GET request?What's the difference between @Component, @Repository & @Service annotations in Spring?Need help on RestTemplate Post Request with Body Parameters?Spring Android Get Request implementation : Could not extract response: no suitable HttpMessageConverter found for response type and content typeSpring 4.1.0 RestTemplate POST callHandle multipart/mixed response with Spring RestTemplateConsuming HAL-based REST service with spring-hateoasProper way to parse the body of an error with Spring's RestTemplatespring restTemplate dynamic mappingSpring RestTemplate + Basic Authentication + Post with request Body: 500 Internal Server Error



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















In my Spring web application I need to make an HTTP request to a non-RESTful API, and parse the response body back as a String (it's a single-dimension CSV list).



I've used RestTemplate before, but this isn't RESTful and doesn't map nicely on to classes. Whenever I implement something like this 'by hand' (eg using HttpClient) I invariably find out later that Spring has a utility class that makes things much simpler.



Is there anything in Spring that will do this job 'out of the box'?










share|improve this question




























    2















    In my Spring web application I need to make an HTTP request to a non-RESTful API, and parse the response body back as a String (it's a single-dimension CSV list).



    I've used RestTemplate before, but this isn't RESTful and doesn't map nicely on to classes. Whenever I implement something like this 'by hand' (eg using HttpClient) I invariably find out later that Spring has a utility class that makes things much simpler.



    Is there anything in Spring that will do this job 'out of the box'?










    share|improve this question
























      2












      2








      2








      In my Spring web application I need to make an HTTP request to a non-RESTful API, and parse the response body back as a String (it's a single-dimension CSV list).



      I've used RestTemplate before, but this isn't RESTful and doesn't map nicely on to classes. Whenever I implement something like this 'by hand' (eg using HttpClient) I invariably find out later that Spring has a utility class that makes things much simpler.



      Is there anything in Spring that will do this job 'out of the box'?










      share|improve this question














      In my Spring web application I need to make an HTTP request to a non-RESTful API, and parse the response body back as a String (it's a single-dimension CSV list).



      I've used RestTemplate before, but this isn't RESTful and doesn't map nicely on to classes. Whenever I implement something like this 'by hand' (eg using HttpClient) I invariably find out later that Spring has a utility class that makes things much simpler.



      Is there anything in Spring that will do this job 'out of the box'?







      web-services spring httpclient resttemplate






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 1 '11 at 16:58









      EngineerBetter_DJEngineerBetter_DJ

      6,0101364140




      6,0101364140






















          2 Answers
          2






          active

          oldest

          votes


















          3














          If you look at the source of RestTemplate you will find that internally it uses



          java.net.URL


          and



          url.openConnection()


          that is the standard way in Java to make HTTP calls, so you are safe to use that. If there would be a "HTTP client" utility in spring then the RestTemplate would use that too.






          share|improve this answer






























            1














            I use the Spring Boot with Spring 4.3 Core inside and found a very simple way to make Http request and read responses by using OkHttpClient. Here is the code



            Request request = new Request.Builder().method("PUT", "some your request body")
            .url(YOUR_URL)
            .build();
            OkHttpClient httpClient = new OkHttpClient();
            try

            Response response = httpClient.newBuilder()
            .readTimeout(1, TimeUnit.SECONDS)
            .build()
            .newCall(request)
            .execute();
            if(response.isSuccessful())

            // notification about succesful request

            else

            // notification about failure request


            catch (IOException e1)

            // notification about other problems






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7969969%2fsimplest-way-to-make-http-request-in-spring%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              3














              If you look at the source of RestTemplate you will find that internally it uses



              java.net.URL


              and



              url.openConnection()


              that is the standard way in Java to make HTTP calls, so you are safe to use that. If there would be a "HTTP client" utility in spring then the RestTemplate would use that too.






              share|improve this answer



























                3














                If you look at the source of RestTemplate you will find that internally it uses



                java.net.URL


                and



                url.openConnection()


                that is the standard way in Java to make HTTP calls, so you are safe to use that. If there would be a "HTTP client" utility in spring then the RestTemplate would use that too.






                share|improve this answer

























                  3












                  3








                  3







                  If you look at the source of RestTemplate you will find that internally it uses



                  java.net.URL


                  and



                  url.openConnection()


                  that is the standard way in Java to make HTTP calls, so you are safe to use that. If there would be a "HTTP client" utility in spring then the RestTemplate would use that too.






                  share|improve this answer













                  If you look at the source of RestTemplate you will find that internally it uses



                  java.net.URL


                  and



                  url.openConnection()


                  that is the standard way in Java to make HTTP calls, so you are safe to use that. If there would be a "HTTP client" utility in spring then the RestTemplate would use that too.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 2 '11 at 10:21









                  Peter SzantoPeter Szanto

                  5,29713243




                  5,29713243























                      1














                      I use the Spring Boot with Spring 4.3 Core inside and found a very simple way to make Http request and read responses by using OkHttpClient. Here is the code



                      Request request = new Request.Builder().method("PUT", "some your request body")
                      .url(YOUR_URL)
                      .build();
                      OkHttpClient httpClient = new OkHttpClient();
                      try

                      Response response = httpClient.newBuilder()
                      .readTimeout(1, TimeUnit.SECONDS)
                      .build()
                      .newCall(request)
                      .execute();
                      if(response.isSuccessful())

                      // notification about succesful request

                      else

                      // notification about failure request


                      catch (IOException e1)

                      // notification about other problems






                      share|improve this answer



























                        1














                        I use the Spring Boot with Spring 4.3 Core inside and found a very simple way to make Http request and read responses by using OkHttpClient. Here is the code



                        Request request = new Request.Builder().method("PUT", "some your request body")
                        .url(YOUR_URL)
                        .build();
                        OkHttpClient httpClient = new OkHttpClient();
                        try

                        Response response = httpClient.newBuilder()
                        .readTimeout(1, TimeUnit.SECONDS)
                        .build()
                        .newCall(request)
                        .execute();
                        if(response.isSuccessful())

                        // notification about succesful request

                        else

                        // notification about failure request


                        catch (IOException e1)

                        // notification about other problems






                        share|improve this answer

























                          1












                          1








                          1







                          I use the Spring Boot with Spring 4.3 Core inside and found a very simple way to make Http request and read responses by using OkHttpClient. Here is the code



                          Request request = new Request.Builder().method("PUT", "some your request body")
                          .url(YOUR_URL)
                          .build();
                          OkHttpClient httpClient = new OkHttpClient();
                          try

                          Response response = httpClient.newBuilder()
                          .readTimeout(1, TimeUnit.SECONDS)
                          .build()
                          .newCall(request)
                          .execute();
                          if(response.isSuccessful())

                          // notification about succesful request

                          else

                          // notification about failure request


                          catch (IOException e1)

                          // notification about other problems






                          share|improve this answer













                          I use the Spring Boot with Spring 4.3 Core inside and found a very simple way to make Http request and read responses by using OkHttpClient. Here is the code



                          Request request = new Request.Builder().method("PUT", "some your request body")
                          .url(YOUR_URL)
                          .build();
                          OkHttpClient httpClient = new OkHttpClient();
                          try

                          Response response = httpClient.newBuilder()
                          .readTimeout(1, TimeUnit.SECONDS)
                          .build()
                          .newCall(request)
                          .execute();
                          if(response.isSuccessful())

                          // notification about succesful request

                          else

                          // notification about failure request


                          catch (IOException e1)

                          // notification about other problems







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 22 at 6:23









                          Vitaly VlasovVitaly Vlasov

                          374




                          374



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7969969%2fsimplest-way-to-make-http-request-in-spring%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

                              밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

                              1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴