Fork me on GitHub

Command Line Examples

Here are examples with `curl` command (See http://jukkaz.wordpress.com/2009/11/24/jackrabbit-over-http/ for detail about the original examples.):

Creating a node - creates 'hello' node under the root node:

$ curl --request MKCOL --data @- --user admin:admin \
  http://localhost:8080/cms/server/default/jcr:root/hello/ <<END
<sv:node sv:name="hello" xmlns:sv="http://www.jcp.org/jcr/sv/1.0">
  <sv:property sv:name="message" sv:type="String">
    <sv:value>Hello, World!</sv:value>
  </sv:property>
  <sv:property sv:name="date" sv:type="Date">
    <sv:value>2012-12-31T12:00:00.000Z</sv:value>
  </sv:property>
</sv:node>
END
          

If you set the init parameter, doMkcolOnPost, to true (false by default) for the JCRWebdavServer servlet (see Installation page), then you can use POST method as well as MKCOL method to create a node like the following:

$ curl --request POST --header "Content-Type: application/xml" --data @- --user admin:admin \
  http://localhost:8080/cms/server/default/jcr:root/hello/ <<END
<sv:node sv:name="hello" xmlns:sv="http://www.jcp.org/jcr/sv/1.0">
  <sv:property sv:name="message" sv:type="String">
    <sv:value>Hello, World!</sv:value>
  </sv:property>
  <sv:property sv:name="date" sv:type="Date">
    <sv:value>2012-12-31T12:00:00.000Z</sv:value>
  </sv:property>
</sv:node>
END
          

Read the node:

$ curl --user admin:admin http://localhost:8080/cms/server/default/jcr:root/hello/

<?xml version="1.0" encoding="UTF-8"?>
<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="hello">
  <sv:property sv:name="jcr:primaryType" sv:type="Name">
    <sv:value>nt:unstructured</sv:value>
  </sv:property>
  <sv:property sv:name="date" sv:type="Date">
    <sv:value>2012-12-31T12:00:00.000Z</sv:value>
  </sv:property>
  <sv:property sv:name="message" sv:type="String">
    <sv:value>Hello, World!</sv:value>
  </sv:property>
</sv:node>
          

Update 'date' property of the 'hello' node:

$ curl --request PUT --header "Content-Type: jcr-value/date" \
  --data "2012-12-30T12:00:00.000Z" --user admin:admin \
  http://localhost:8080/server/default/jcr:root/hello/date
          

Update 'history' property of the 'hello' node:

$ curl --request PUT --header "Content-Type: jcr-value/string" \
  --data "Document data updated" --user admin:admin \
  http://localhost:8080/cms/server/default/jcr:root/hello/history
          

Delete the node:

$ curl --request DELETE --user admin:admin \
  http://localhost:8080/cms/server/default/jcr:root/hello/
          

Get the metadata of the node:

A PROPFIND request with "Depth: 0" HTTP header will return an XML response with the node metadata:.

Note: The Depth HTTP header supports only 0, 1 and "infinity" as shown below. It will result in 400 (Bad Request) error if specified with other values.

$ curl --request PROPFIND --header "Depth: 0" --user admin:admin \
  http://localhost:8080/cms/server/default/jcr:root/hst:hst/

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<D:multistatus xmlns:D="DAV:">
  <D:response>
    <D:href>http://localhost:8080/cms/server/default/jcr%3aroot/hst%3ahst/</D:href>
    <D:propstat>
      <D:prop>
        <D:creationdate>1970-01-01T00:00:00Z</D:creationdate>
        <dcr:name xmlns:dcr="http://www.day.com/jcr/webdav/1.0">hst:hst</dcr:name>
        <dcr:depth xmlns:dcr="http://www.day.com/jcr/webdav/1.0">1</dcr:depth>
        <D:getlastmodified>Sun, 04 Aug 2019 14:11:01 GMT</D:getlastmodified>
        <D:iscollection>1</D:iscollection>
        <dcr:mixinnodetypes xmlns:dcr="http://www.day.com/jcr/webdav/1.0"/>
        <!-- SNIP -->
        <D:resourcetype><D:collection/></D:resourcetype>
        <!-- SNIP -->
        <dcr:primarynodetype xmlns:dcr="http://www.day.com/jcr/webdav/1.0">
          <dcr:nodetype>
            <dcr:nodetypename>hst:hst</dcr:nodetypename>
          </dcr:nodetype>
        </dcr:primarynodetype>
        <D:displayname>hst:hst</D:displayname>
        <!-- SNIP -->
        <dcr:path xmlns:dcr="http://www.day.com/jcr/webdav/1.0">/hst:hst</dcr:path>
        <dcr:workspaceName xmlns:dcr="http://www.day.com/jcr/webdav/1.0">default</dcr:workspaceName>
      </D:prop>
      <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
  </D:response>
</D:multistatus>
          

Get the metadata of the node and its child nodes:

A PROPFIND request with "Depth: 1" HTTP header will return an XML response with the metadata of the node and its child nodes, each of which is wrapped in a separate <D:response> element.

$ curl --request PROPFIND --header "Depth: 1" --user admin:admin \
  http://localhost:8080/cms/server/default/jcr:root/hst:hst/

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<D:multistatus>
  <D:response>
    <D:href>http://localhost:8080/cms/server/default/jcr%3aroot/hst%3ahst/</D:href>
    <D:propstat>
      <D:prop>
        <D:creationdate>1970-01-01T00:00:00Z</D:creationdate>
        <dcr:name>hst:hst</dcr:name>
        <dcr:depth>1</dcr:depth>
        <D:getlastmodified>Sun, 04 Aug 2019 13:58:48 GMT</D:getlastmodified>
        <D:iscollection>1</D:iscollection>
        <dcr:mixinnodetypes/>
        <!-- SNIP -->
        <dcr:primarynodetype>
          <dcr:nodetype>
            <dcr:nodetypename>hst:hst</dcr:nodetypename>
          </dcr:nodetype>
        </dcr:primarynodetype>
        <D:displayname>hst:hst</D:displayname>
        <!-- SNIP -->
        <dcr:path>/hst:hst</dcr:path>
        <dcr:workspaceName>default</dcr:workspaceName>
      </D:prop>
      <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
  </D:response>
  <D:response>
    <D:href>http://localhost:8080/cms/server/default/jcr%3aroot/hst%3ahst/hst%3aconfigurations/</D:href>
    <D:propstat>
      <D:prop>
        <D:creationdate>1970-01-01T00:00:00Z</D:creationdate>
        <dcr:name>hst:configurations</dcr:name>
        <dcr:depth>2</dcr:depth>
        <D:getlastmodified>Sun, 04 Aug 2019 13:58:48 GMT</D:getlastmodified>
        <D:iscollection>1</D:iscollection>
        <dcr:mixinnodetypes/>
        <!-- SNIP -->
        <dcr:primarynodetype>
          <dcr:nodetype>
            <dcr:nodetypename>hst:configurations</dcr:nodetypename>
          </dcr:nodetype>
        </dcr:primarynodetype>
        <D:displayname>hst:configurations</D:displayname>
        <!-- SNIP -->
        <dcr:path>/hst:hst/hst:configurations</dcr:path>
        <dcr:workspaceName>default</dcr:workspaceName>
      </D:prop>
      <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
  </D:response>
  <!-- SNIP -->
</D:multistatus>
          

Get the metadata of the node and all its descendant nodes:

A PROPFIND request with "Depth: infinity" HTTP header will return an XML response with the metadata of the node and all its descendant nodes, each of which is wrapped in a separate <D:response> element.

$ curl --request PROPFIND --header "Depth: infinity" --user admin:admin \
  http://localhost:8080/cms/server/default/jcr:root/hst:hst/

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<D:multistatus>
  <!-- SNIP -->
</D:multistatus>