Create a multi-statement transaction. The resulting transaction id
may be used in the txid
request parameter of subsequent
requests to force evaluation to take place in the context of the created
transaction.
URL Parameters | |
---|---|
name |
A symbolic name for the transaction. Default: client-txn .
|
timeLimit |
The transaction time limit to apply to this transaction, in seconds.
Default: The request timeout configured for the App Server. If the
transaction is not committed or rolled back within this time limit,
the transaction is automatically rolled back. You may not set the
limit to a value greater than the default request timeout configured
for the App Server. For details, see
xdmp:set-transaction-time-limit .
|
database? | Perform this operation on the named content database instead of the default content database associated with the REST API instance. Using an alternative database requires the "eval-in" privilege; for details, see Security Requirements in the REST Application Developer's Guide. |
Response Headers | |
---|---|
Location |
Upon success, the Location header contains a transaction URI of the
form /v1/transactions/ txid. Use the
txid portion in the txid parameter or
URI of subsequent requests.
|
Upon success, MarkLogic Server returns a status 303 (See Created
Transaction) and returns the transaction id in the Location
response header.
rest-writer
role, or the
following privileges:
http://marklogic.com/xdmp/privileges/rest-writer
http://marklogic.com/xdmp/privileges/rest-reader
By default, each REST request is serviced in a single transaction.
The transaction is committed (or rolled back, in the case of error)
automatically before the response sent. Use this request to create a
transaction that can service multiple requests. Pass the transaction
id in the txid
parameter of subsequent requests to service
a request in the created transaction.
Transactions created in this way should be explicitly committed or
rolled back using the /transactions
service. Transactions
which are not explicitly committed are rolled back when the session or
request times out.
For more details, see Understanding Transactions in MarkLogic Server in the Application Developer's Guide and Creating a Transaction in the REST Application Developer's Guide.
$ curl --anyauth --user user:password -X POST -d "" -i \ -H "Content-type: text/plain" \ http://localhost:8004/v1/transactions ==> A transaction is created. MarkLogic Server returns the transaction ID is returned in the Location header of the response. Use the contents of the Location header as the value of the "txid" parameter in other methods. The transaction ID is of the form /transactions/transactionid. For example, the following headers are returned: Server: MarkLogic Content-Type: text/plain; charset=UTF-8 Content-Length: 31 Connection: close HTTP/1.1 303 See Created Transaction Location: /transactions/3148548124558550433 Server: MarkLogic Content-Length: 0 Connection: close
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.