Apache HTTP client equivalent of CURL command to configure shapefilesGet parameter from curl command in REST web serivcejava compilation: classname Vs classname with file-extensionCompile all files in src?How do Jersey-client and Apache HTTP Client compare?Dynamically configuring Apache Http clientUpload a file from java client to a apache http serverHTTPClient Example - Exception in thread “main” java.lang.NoSuchFieldError: INSTANCEIs it possible to write a program in Java without main() using JDK 1.7 or higher?Trouble running something from the consoleConnection reset by peer: socket write error httpclient and geoserver

Four ships at the ocean with the same distance

How many Jimmys can fit?

How can a person with a similar experience with the defendant, help the plaintiff in a lawsuit?

Is space division multiplexing really multiplexing?

Wires do not connect in Circuitikz

Is this car delivery via Ebay Motors on Craigslist a scam?

Is it possible for a character at any level to cast all 44 Cantrips in one week without Magic Items?

Tesco's Burger Relish Best Before End date number

Interpretation of non-significant results as "trends"

How do "gefälligst" and "ruhig" have different tones?

How can I use my cell phone's light as a reading light?

Is there a formal/better word than "skyrocket" for the given context?

How to slice a string input at a certain unknown index

Who goes first? Person disembarking bus or the bicycle?

Passwordless authentication - how and when to invalidate a login code

Sense of humor in your sci-fi stories

Gory anime with pink haired girl escaping an asylum

Very Simple Spell (Number to Words) 001 to 999 in VBA

Other Space Shuttle O-ring failures

As a supervisor, what feedback would you expect from a PhD who quits?

Is it possible to complete a PhD in CS in 3 years?

A ring of generalized power series

Strong Password Detection in Python

Curly braces adjustment in tikz?



Apache HTTP client equivalent of CURL command to configure shapefiles


Get parameter from curl command in REST web serivcejava compilation: classname Vs classname with file-extensionCompile all files in src?How do Jersey-client and Apache HTTP Client compare?Dynamically configuring Apache Http clientUpload a file from java client to a apache http serverHTTPClient Example - Exception in thread “main” java.lang.NoSuchFieldError: INSTANCEIs it possible to write a program in Java without main() using JDK 1.7 or higher?Trouble running something from the consoleConnection reset by peer: socket write error httpclient and geoserver






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















What is the equivalent of httpclient code for the following CURL command




curl -v -u username:password-XPUT -H "Content-type: text/plain" -d "E:/path_to_shapefile/shapefiles/" "http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all"


The CURL command works fine. I have limited knowledge of httpclient, however, adapting similar code, following is my attempt:




import org.apache.http.client.fluent.*;

public class QuickStart
public static void main(String[] args) throws Exception
Executor executor = Executor.newInstance()
.auth("username", "password")
.authPreemptive("172.16.17.86:9090");
// Line below does not compile
String response = executor.execute(Request.Put("E:/path_to_shapefile/shapefiles/"
"http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all"))
.returnResponse()
.toString();
System.out.println(response);




This code above does not compile since I do not know how to encode two urls in the same request as in the CURL command. A fix to the above code or a new approach would be appreciated.



Thanks in advance.










share|improve this question




























    1















    What is the equivalent of httpclient code for the following CURL command




    curl -v -u username:password-XPUT -H "Content-type: text/plain" -d "E:/path_to_shapefile/shapefiles/" "http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all"


    The CURL command works fine. I have limited knowledge of httpclient, however, adapting similar code, following is my attempt:




    import org.apache.http.client.fluent.*;

    public class QuickStart
    public static void main(String[] args) throws Exception
    Executor executor = Executor.newInstance()
    .auth("username", "password")
    .authPreemptive("172.16.17.86:9090");
    // Line below does not compile
    String response = executor.execute(Request.Put("E:/path_to_shapefile/shapefiles/"
    "http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all"))
    .returnResponse()
    .toString();
    System.out.println(response);




    This code above does not compile since I do not know how to encode two urls in the same request as in the CURL command. A fix to the above code or a new approach would be appreciated.



    Thanks in advance.










    share|improve this question
























      1












      1








      1








      What is the equivalent of httpclient code for the following CURL command




      curl -v -u username:password-XPUT -H "Content-type: text/plain" -d "E:/path_to_shapefile/shapefiles/" "http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all"


      The CURL command works fine. I have limited knowledge of httpclient, however, adapting similar code, following is my attempt:




      import org.apache.http.client.fluent.*;

      public class QuickStart
      public static void main(String[] args) throws Exception
      Executor executor = Executor.newInstance()
      .auth("username", "password")
      .authPreemptive("172.16.17.86:9090");
      // Line below does not compile
      String response = executor.execute(Request.Put("E:/path_to_shapefile/shapefiles/"
      "http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all"))
      .returnResponse()
      .toString();
      System.out.println(response);




      This code above does not compile since I do not know how to encode two urls in the same request as in the CURL command. A fix to the above code or a new approach would be appreciated.



      Thanks in advance.










      share|improve this question














      What is the equivalent of httpclient code for the following CURL command




      curl -v -u username:password-XPUT -H "Content-type: text/plain" -d "E:/path_to_shapefile/shapefiles/" "http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all"


      The CURL command works fine. I have limited knowledge of httpclient, however, adapting similar code, following is my attempt:




      import org.apache.http.client.fluent.*;

      public class QuickStart
      public static void main(String[] args) throws Exception
      Executor executor = Executor.newInstance()
      .auth("username", "password")
      .authPreemptive("172.16.17.86:9090");
      // Line below does not compile
      String response = executor.execute(Request.Put("E:/path_to_shapefile/shapefiles/"
      "http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all"))
      .returnResponse()
      .toString();
      System.out.println(response);




      This code above does not compile since I do not know how to encode two urls in the same request as in the CURL command. A fix to the above code or a new approach would be appreciated.



      Thanks in advance.







      java apache-httpclient-4.x






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 22:15









      Anand VeeraswamyAnand Veeraswamy

      243 bronze badges




      243 bronze badges






















          2 Answers
          2






          active

          oldest

          votes


















          0














          import org.apache.http.client.fluent.*;
          import org.apache.http.entity.ContentType;

          public class QuickStart
          public static void main(String[] args) throws Exception
          Executor executor = Executor.newInstance()
          .auth("admin", "geoserver")
          .authPreemptive("172.16.17.86:9090");
          String response = executor.execute(Request.Put("http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all")
          .bodyString("E:\Tomcat\apache-tomcat-8.5.37\webapps\geoserver\data\data\IDIRA6\scenario2373\", ContentType.create("text/plain")))
          .returnResponse()
          .toString();
          System.out.println(response);







          share|improve this answer




















          • 1





            I think this looks right - but if at all possible, try not to use authPreemptive - use auth(HttpHost, String, String) this way you're not sending an authentication without being challenged

            – Dave G
            Mar 26 at 3:36











          • Sorry should have clarified this. This is a client side program. The files are located on a remote server and thus the client program only needs to specify the location of the files and not include the actual file. However, I don't understand how to specify this file location in the java code.

            – Anand Veeraswamy
            Mar 26 at 11:04


















          0














          Thanks for the answer. I replaced bodyFile by bodyString and that worked.



          import org.apache.http.client.fluent.*;
          import org.apache.http.entity.ContentType;

          public class QuickStart
          public static void main(String[] args) throws Exception
          Executor executor = Executor.newInstance()
          .auth("admin", "geoserver")
          .authPreemptive("172.16.17.86:9090");
          String response = executor.execute(Request.Put("http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all")
          .bodyString("E:\Tomcat\apache-tomcat-8.5.37\webapps\geoserver\data\data\IDIRA6\scenario2373\", ContentType.create("text/plain")))
          .returnResponse()
          .toString();
          System.out.println(response);







          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%2f55347196%2fapache-http-client-equivalent-of-curl-command-to-configure-shapefiles%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









            0














            import org.apache.http.client.fluent.*;
            import org.apache.http.entity.ContentType;

            public class QuickStart
            public static void main(String[] args) throws Exception
            Executor executor = Executor.newInstance()
            .auth("admin", "geoserver")
            .authPreemptive("172.16.17.86:9090");
            String response = executor.execute(Request.Put("http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all")
            .bodyString("E:\Tomcat\apache-tomcat-8.5.37\webapps\geoserver\data\data\IDIRA6\scenario2373\", ContentType.create("text/plain")))
            .returnResponse()
            .toString();
            System.out.println(response);







            share|improve this answer




















            • 1





              I think this looks right - but if at all possible, try not to use authPreemptive - use auth(HttpHost, String, String) this way you're not sending an authentication without being challenged

              – Dave G
              Mar 26 at 3:36











            • Sorry should have clarified this. This is a client side program. The files are located on a remote server and thus the client program only needs to specify the location of the files and not include the actual file. However, I don't understand how to specify this file location in the java code.

              – Anand Veeraswamy
              Mar 26 at 11:04















            0














            import org.apache.http.client.fluent.*;
            import org.apache.http.entity.ContentType;

            public class QuickStart
            public static void main(String[] args) throws Exception
            Executor executor = Executor.newInstance()
            .auth("admin", "geoserver")
            .authPreemptive("172.16.17.86:9090");
            String response = executor.execute(Request.Put("http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all")
            .bodyString("E:\Tomcat\apache-tomcat-8.5.37\webapps\geoserver\data\data\IDIRA6\scenario2373\", ContentType.create("text/plain")))
            .returnResponse()
            .toString();
            System.out.println(response);







            share|improve this answer




















            • 1





              I think this looks right - but if at all possible, try not to use authPreemptive - use auth(HttpHost, String, String) this way you're not sending an authentication without being challenged

              – Dave G
              Mar 26 at 3:36











            • Sorry should have clarified this. This is a client side program. The files are located on a remote server and thus the client program only needs to specify the location of the files and not include the actual file. However, I don't understand how to specify this file location in the java code.

              – Anand Veeraswamy
              Mar 26 at 11:04













            0












            0








            0







            import org.apache.http.client.fluent.*;
            import org.apache.http.entity.ContentType;

            public class QuickStart
            public static void main(String[] args) throws Exception
            Executor executor = Executor.newInstance()
            .auth("admin", "geoserver")
            .authPreemptive("172.16.17.86:9090");
            String response = executor.execute(Request.Put("http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all")
            .bodyString("E:\Tomcat\apache-tomcat-8.5.37\webapps\geoserver\data\data\IDIRA6\scenario2373\", ContentType.create("text/plain")))
            .returnResponse()
            .toString();
            System.out.println(response);







            share|improve this answer















            import org.apache.http.client.fluent.*;
            import org.apache.http.entity.ContentType;

            public class QuickStart
            public static void main(String[] args) throws Exception
            Executor executor = Executor.newInstance()
            .auth("admin", "geoserver")
            .authPreemptive("172.16.17.86:9090");
            String response = executor.execute(Request.Put("http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all")
            .bodyString("E:\Tomcat\apache-tomcat-8.5.37\webapps\geoserver\data\data\IDIRA6\scenario2373\", ContentType.create("text/plain")))
            .returnResponse()
            .toString();
            System.out.println(response);








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 27 at 14:10









            Anand Veeraswamy

            243 bronze badges




            243 bronze badges










            answered Mar 25 at 23:04









            Not a JDNot a JD

            1,4021 silver badge12 bronze badges




            1,4021 silver badge12 bronze badges







            • 1





              I think this looks right - but if at all possible, try not to use authPreemptive - use auth(HttpHost, String, String) this way you're not sending an authentication without being challenged

              – Dave G
              Mar 26 at 3:36











            • Sorry should have clarified this. This is a client side program. The files are located on a remote server and thus the client program only needs to specify the location of the files and not include the actual file. However, I don't understand how to specify this file location in the java code.

              – Anand Veeraswamy
              Mar 26 at 11:04












            • 1





              I think this looks right - but if at all possible, try not to use authPreemptive - use auth(HttpHost, String, String) this way you're not sending an authentication without being challenged

              – Dave G
              Mar 26 at 3:36











            • Sorry should have clarified this. This is a client side program. The files are located on a remote server and thus the client program only needs to specify the location of the files and not include the actual file. However, I don't understand how to specify this file location in the java code.

              – Anand Veeraswamy
              Mar 26 at 11:04







            1




            1





            I think this looks right - but if at all possible, try not to use authPreemptive - use auth(HttpHost, String, String) this way you're not sending an authentication without being challenged

            – Dave G
            Mar 26 at 3:36





            I think this looks right - but if at all possible, try not to use authPreemptive - use auth(HttpHost, String, String) this way you're not sending an authentication without being challenged

            – Dave G
            Mar 26 at 3:36













            Sorry should have clarified this. This is a client side program. The files are located on a remote server and thus the client program only needs to specify the location of the files and not include the actual file. However, I don't understand how to specify this file location in the java code.

            – Anand Veeraswamy
            Mar 26 at 11:04





            Sorry should have clarified this. This is a client side program. The files are located on a remote server and thus the client program only needs to specify the location of the files and not include the actual file. However, I don't understand how to specify this file location in the java code.

            – Anand Veeraswamy
            Mar 26 at 11:04













            0














            Thanks for the answer. I replaced bodyFile by bodyString and that worked.



            import org.apache.http.client.fluent.*;
            import org.apache.http.entity.ContentType;

            public class QuickStart
            public static void main(String[] args) throws Exception
            Executor executor = Executor.newInstance()
            .auth("admin", "geoserver")
            .authPreemptive("172.16.17.86:9090");
            String response = executor.execute(Request.Put("http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all")
            .bodyString("E:\Tomcat\apache-tomcat-8.5.37\webapps\geoserver\data\data\IDIRA6\scenario2373\", ContentType.create("text/plain")))
            .returnResponse()
            .toString();
            System.out.println(response);







            share|improve this answer



























              0














              Thanks for the answer. I replaced bodyFile by bodyString and that worked.



              import org.apache.http.client.fluent.*;
              import org.apache.http.entity.ContentType;

              public class QuickStart
              public static void main(String[] args) throws Exception
              Executor executor = Executor.newInstance()
              .auth("admin", "geoserver")
              .authPreemptive("172.16.17.86:9090");
              String response = executor.execute(Request.Put("http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all")
              .bodyString("E:\Tomcat\apache-tomcat-8.5.37\webapps\geoserver\data\data\IDIRA6\scenario2373\", ContentType.create("text/plain")))
              .returnResponse()
              .toString();
              System.out.println(response);







              share|improve this answer

























                0












                0








                0







                Thanks for the answer. I replaced bodyFile by bodyString and that worked.



                import org.apache.http.client.fluent.*;
                import org.apache.http.entity.ContentType;

                public class QuickStart
                public static void main(String[] args) throws Exception
                Executor executor = Executor.newInstance()
                .auth("admin", "geoserver")
                .authPreemptive("172.16.17.86:9090");
                String response = executor.execute(Request.Put("http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all")
                .bodyString("E:\Tomcat\apache-tomcat-8.5.37\webapps\geoserver\data\data\IDIRA6\scenario2373\", ContentType.create("text/plain")))
                .returnResponse()
                .toString();
                System.out.println(response);







                share|improve this answer













                Thanks for the answer. I replaced bodyFile by bodyString and that worked.



                import org.apache.http.client.fluent.*;
                import org.apache.http.entity.ContentType;

                public class QuickStart
                public static void main(String[] args) throws Exception
                Executor executor = Executor.newInstance()
                .auth("admin", "geoserver")
                .authPreemptive("172.16.17.86:9090");
                String response = executor.execute(Request.Put("http://172.16.17.86:9090/geoserver/rest/workspaces/IDIRA6/datastores/scenario2373/external.shp?configure=all")
                .bodyString("E:\Tomcat\apache-tomcat-8.5.37\webapps\geoserver\data\data\IDIRA6\scenario2373\", ContentType.create("text/plain")))
                .returnResponse()
                .toString();
                System.out.println(response);








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 26 at 12:51









                Anand VeeraswamyAnand Veeraswamy

                243 bronze badges




                243 bronze badges



























                    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%2f55347196%2fapache-http-client-equivalent-of-curl-command-to-configure-shapefiles%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

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해