3 Replies Latest reply on Feb 24, 2012 5:03 PM by cvasilak

    curl - HTTP Management

    cvasilak

      Hi all,

       

      trying to execute POST through curl from the console  as described here https://community.jboss.org/wiki/HTTPJSON-likeAPI

      curl -H Content-Type:\ application/json -d '{"operation":"read-resource","address":[],"json.pretty":1}'  http://localhost:9990/management 

      curl: (52) Empty reply from server.

       

      The GET from the browser works though

      http://localhost:9990/management?operation=resource&json.pretty=true

       

      Am I doing sth wrong..?

       

      I have two more questions

       

      1. What is the correct way to specify the address when doing POST e.g. for sth like /management/subsystem/logging/console-handler/CONSOLE ?

      2. As I understand only read-* commands are allowed for GET requests,  if I do POST am I allowed to access anything? I am thinking of write-attribute to change configuration parameters and other operations that each resource provides (deploy, undeploy, shutdown etc).

       

      Regards

        • 1. Re: curl - HTTP Management
          dlofthouse

          Have you added a user for domain management?  You are going to need to specify their username in the curl call and provide their password.

          • 2. Re: curl - HTTP Management
            ctomc

            Hi,

             

            you can find an example how to call management with curl here:

             

            https://docs.jboss.org/author/display/AS71/The+HTTP+management+API

             

             

            --

            tomaz

            • 3. Re: curl - HTTP Management
              cvasilak

              thanks for your replies,

               

              although I didn't show in the command line I was using basic authentication from curl. After changing to --digest all works ok e.g.

               

              cvasilak@casper:~$ curl --digest -D - http://localhost:9990/management --header "Content-Type: application/json" -d '{"operation":"read-resource", "address":["deployment","jolokia.war"], "json.pretty":1}' -u username:password
              HTTP/1.1 401 Unauthorized
              Content-length: 0
              Www-authenticate: Digest realm="ManagementRealm",nonce="e371e4c9d9c8e9a54ba00f1211541fdb"
              Date: Fri, 24 Feb 2012 21:56:26 GMT
              
              HTTP/1.1 200 OK
              Transfer-encoding: chunked
              Content-type: application/json
              Date: Fri, 24 Feb 2012 21:56:26 GMT
              
              {
                  "outcome" : "success",
                  "result" : {
                      "content" : [{
                          "path" : "deployments/jolokia.war",
                          "relative-to" : "jboss.server.base.dir",
                          "archive" : true
                      }],
                      "enabled" : true,
                      "name" : "jolokia.war",
                      "persistent" : false,
                      "runtime-name" : "jolokia.war",
                      "subdeployment" : null,
                      "subsystem" : {"web" : null}
              

               

               

              As you can see the "address" part is a standard json array so after populating correctly it works fluently. Plus after changing the operation to "redeploy" the war was redeployed. So I guess I have the full power

               

              Time for serious fun...

               

              Thanks a lot!

               

              Regards