Link Search Menu Expand Document
Domino REST API
Released!

Using Postman and curl

This tutorial shows how to configure and use a database using Postman and curl. Download the database Demo.nsf from Resources and follow along. We also have a Postman collection under Resources to download and used for quick learning.

Prepare database access

First, copy the demo database to the server.

Download demo.nsf. Then, use the following command to copy demo.nsf to the server. Replace $Server with actual docker container name/ server name.

docker cp Demo.nsf $Server:/local/notesdata

to check if you have copied it successfully, you may try to run this command

docker exec -it `$Server` /bin/bash
cd local/notesdata

You can use ls command to check Demo.nsf among the lists of files in notesdata directory

Login

Provide the user name and password for login.

Login

Curl code snippet

Replace $password with actual password value and $username with actual user name value.

curl --location --request POST 'localhost:8880/api/v1/auth' \
--header 'Content-Type: application/json' \
--data-raw '{
"password" : $password,
 "username" : $username
}'

List available databases

Use the following command to list all the databases:

AllDatabases

Curl code snippet

Replace $Bearer with the actual Bearer value.

curl --location --request POST 'localhost:8880/api/v1/admin/access' \
--header 'Authorization: Bearer $Bearer' \
--header 'Content-Type: application/json' \
--data-raw '{
    "checkAllNsf": true,
    "onlyConfigured": false
}'

Verify the views and forms for the demo database

Use the following commands to check the views and forms in the database.

PostmanViews

Curl code snippet

Please replace $Bearer with actual Bearer value.

curl --location --request GET 'localhost:8880/api/v1/lists?dataSource=demo' \
--header 'Authorization: Bearer $Bearer' \
--header 'Accept: application/json'

PostmanForms

Curl code snippet

Please replace $Bearer with actual Bearer value.

curl --location --request GET 'localhost:8880/api/v1/design/forms?dataSource=demo' \
--header 'Authorization: Bearer $Bearer'

Create document

Use the following command to provide the body for the create document POST request.

CreateDocument

Curl code snippet

Please replace $Bearer with actual Bearer value.

curl --location --request POST 'localhost:8880/api/v1/document?dataSource=demo' \
--header 'Authorization: Bearer $Bearer' \
--header 'Content-Type: application/json' \
--data-raw '{
    "first_name": "George",
    "last_name": "Branthwaite",
    "email": "gbranthwaite0@nba.com",
    "gender": "Male",
    "ip_address": "91.254.204.27",
    "Color": "Red",
    "Pet": "Black-capped chickadee",
    "Form": "Customer"
}'

Retrieve document

Use the following command to retrieve a document.

RetrieveDocument

Curl code snippet

Please replace $Bearer with actual Bearer value.Also replace `` with actual unid.

curl --location -g --request GET 'localhost:8880/api/v1/document//default?dataSource=demo' \
--header 'Authorization: Bearer $Bearer' \
--header 'Content-Type: application/json' \
--data-raw ''

Delete document

Use the following command to delete a document.

DeleteDocument

Curl code snippet

Please replace $Bearer with actual Bearer value.Also replace `` with actual unid.

curl --location -g --request DELETE 'localhost:8880/api/v1/document//default?dataSource=demo&Form=Customer' \
--header 'Authorization: Bearer $Bearer' \
--header 'Content-Type: application/json' \
--data-raw ''

Verify that the document is deleted

To verify that the document is deleted, try retrieving it again. Retrieve should fail.

DocumentRetrieve

Logout

Use the following command to log out.

Logout

Curl code snippet

Please replace $Bearer with actual Bearer value.

curl --location --request POST 'localhost:8880/api/v1/auth/logout' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $Bearer' \
--data-raw '{"logout" : "Yes"}'

Shutdown

Finally, use the following command to shut down. Provide the body for the POST request.

Shutdown

Curl code snippet

Please replace $Bearer with actual Bearer value.

curl --location --request POST 'http://127.0.0.1:8889/shutdown' \
--header 'Authorization: Bearer $Bearer' \
--header 'Content-Type: application/json' \
--data-raw '{
	"shutdownkey" : "The End is near!!",
	"StopServer" : true
    }'