You want a quick & dirty way to work with XQuery or SJS. Query Console is great for interactively building stuff and for queries, but sometimes the direct-to-filesystem cuts out QC middle man, and also with this approach you can do things with your output, like pipe it to a file, which is a pain with QC.
Applies to MarkLogic versions 8+
Put this in a file called “make-app”:
#!/bin/bash ROOT=`pwd` NAME=$1 PORT=$2 curl --digest --user admin:admin -X POST -Hcontent-type:application/json \ -d"{\"server-name\":\"$NAME\",\"group-name\":\"Default\",\"server-type\":\"http\",\"content-database\":\"Documents\",\"port\":$PORT,\"root\":\"$ROOT\",\"authentication\":\"application-level\",\"default-user\":\"admin\"}" \ https://localhost:8002/manage/v2/servers
Run it like this:
make-app TEST 9999
Now you create a file, say, x.xqy, and run it
curl --digest --user admin:admin https://localhost:9999/x.xqy
Required Privileges:
This recipe uses the Management API to create a new application server that looks at the file system for source code. Specifically, it looks at the directory you’re in when you run the make-app
script. The app server will use the Documents database for content; the app server name and port are specified as parameters to the script.
Notice that the authentication is set to “application-level” and the default user is set to “admin”. This effectively turns off security: the admin user can access all content and run all functions.
Once the app server has been created, you can save any file and easily run it with a curl command or even with a browser (using something like POSTman if you want to send requests with verbs other than GET).
The MarkLogic REST API requires an app server with a modules database, so this won’t work for testing out REST extensions or transforms.
By continuing to use this website you are giving consent to cookies being used in accordance with the MarkLogic Privacy Statement.