Article
· Jan 19, 2021 2m read

Document Database (DocDB) - Sample REST API Calls - Postman Collection

For the benefit of those who want to use the Document Database (DocDB) capabilities within InterSystems IRIS, and specifically the REST API it provides, I put together a Postman Collection that provides samples for several basic calls.

For example:

The example uses "Color" documents, e.g. Red, Blue, etc, using a sample JSON structure from here.

The Collection includes calls of different "categories" -

  • Create Metadata - create the database and related properties
  • Get Metadata - understand what databases and properties are defined
  • CUD - create/update/delete of Documents
  • Find & Get Documents - retrieve documents according to ID or certain values or criteria
  • Delete Metadata - delete properties or databases

The order in which the requests are in the Collection have some internal logic (e.g. first create the database and properties, then insert some data, then retrieve it), but of course you can use it in any order or changes you like.

The order also works well if running the Postman Collection Runner. I added some basic test scripts that allow Postman to display Passed or Failed status for each call.

For example:

Please note the last call deletes all the document databases within a Namespace - so do not run this unless you really mean to... not manually and not as part of running the whole Collection.

In order to make the calls work on various environments I used Postman's variables feature.

This allows you to change the server name/IP, the port, and the namespace -

So every call looks something like this:

You would also probably need to adapt the authentication part.

I currently have "Basic Authentication" with simply 'SuperUser' and 'sys' -

 

Just to add a "Multi-Model" twist to this, here's also an example of accessing this data via SQL -

This is the table structure (as viewed in the SQL Tools extension in VSCode):

This is a simple SELECT result:

And here's a SELECT with a WHERE clause on one of the properties we defined:

Discussion (0)1
Log in or sign up to continue