Database Reference
In-Depth Information
curl -i -X PUT
-H
'Content-Type: application/xml'
--data-binary @/tmp/my-doc.xml
http://aretter:12345@localhost:8080/exist/rest/db/docs/personal/my-doc.xml
Its parameters are explained in
Table 13-2
and its output illustrated in
Figure 13-17
.
Table 13-2. cURL parameters for storing a document
cURL parameters
Explanation
PUT
ing a document into eXist does not return any content. You will know if the
PUT
succeeds by examining the HTTP response code; success is indicated by the code
201
Created
. The
-i
parameter causes cURL to show the HTTP response headers
(including the HTTP response code).
-i
The
-X
parameter allows you to specify the HTTP request method.
In this example the method of the request is
PUT
, as we want to
PUT
the new
resource in the database.
-X PUT
eXist needs to know the Internet media type of the resource you are
PUT
ing so it can
store it correctly. The
-H
parameter allows you to specify an HTTP request header. We
can inform eXist of the Internet media type by setting the
Content-Type
header.
In this example, we use the Internet media type for an XML document.
-H 'Content-Type:
application/xml'
This parameter allows you to send binary data in the body of the request.
In this example we want to send an XML document; the
@
indicates that the data
should be read from the file
/tmp/my-doc.xml
.
--data-binary
@/tmp/
my-doc.xml
The final parameter is always the target URI of the request.
In this instance, we are making the request on the
/db/docs/personal
collection, where
we want to store the data into a resource named
my-doc.xml
. We also specify the
username
aretter
and password
12345
of an account in eXist that has execute
and write access to store the document.
a
http://aretter:
12345@localhost:8080/
exist/rest/db/docs/
personal/my-doc.xml
a
If you do not have execute and write access to store the resource indicated by the
URI of the request, you will receive an HTTP response code of
401 Unauthorized
.
Search WWH ::
Custom Search