Categories
#DCR Active Repository

Using Postman to access DCR Active Repository

Getting started

DCR Active Repository provides a RESTful API to manipulate process models and simulations. This section will give an example of how to use the Postman tool to manipulate processs models and simulations.

We'll provide four examples

  1. Get a list of your process models in DCRGraphs.net
  2. Start simulation of a specific process model
  3. Get a list of enabled or pending events in the simulation
  4. Execute an event in a simulation

Download and install Postman and start the application.

Postman tool started

Get a list of your process models in DCRGraphs.net

Enter the URL https://repository.dcrgraphs.net/api/graphs in the URL line and set the action to GET. Then click Send.You'll then get a 403, access denied, back.

Click on "No Auth" and select "Basic Auth", enter username and password and click Update Request:

Postman Update Request

Then click on Send again

Postman list of DCR process models

The list looks like this:
<graphs>
<graph id="1234" title="My first process model" />
...
</graphs>

Start simulation of a specific process model

Start a simulation by a POST to the following URL: https://repository.dcrgraphs.net/api/graphs/<graphid>/simsAs above, ensure username and password are provided.

Clicking SEND will give returncode 201 and the simulation id

Postman Instantiate process model

x-dcr-simulation-id -> 29535

The returncode is 201 on success.

Get a list of enabled or pending events in the simulation

To get a list of enabled or pending events for a simulation you must do a GET to the following URL: https://repository.dcrgraphs.net/api/graphs/<graphid>/sims/<simid>//events?filter=enabled-or-pending

Postman Get Enabled or Pending events

The events is returned in a format as outlined below:


<events isAccepting="true|false" nextDeadline="..." nextDelay="...">
<event id="Activity0" included="true" enabled="true" pending="false" executed="false" fullPath="Activity0" roles="" groups="" description="" label="Do some work" eventType="" /> </events>

The returncode is 200 on success.

Execute an event in a simulation

Executing an event is done by making at POST to the following URL: https://repository.dcrgraphs.net/api/graphs/<
graphid>/sims/<simid>/events/<eventid>

Postman Execute Event

Execute an event in a simulation with data

Executing an event is done by making at POST to the following URL: https://repository.dcrgraphs.net/api/graphs/<graphid>/sims/<simid>/events/<eventid>

When posting you need to pass the data value:{DataXML:'<globalStore><variable id="Data" value="1" isNull="false" type="int" /></globalStore>'}

Postman Execute Event with data

Notice: The value is XML send as a JSON object.

The returncode is 204 on success.

A comprehensive example

We've prepared a Postman project that can be downloaded from this location.

This example use process model 4013, expense report, check this link for details.

The process is shown below:

Expense example

When an employee fill out an expense report the money must be paid out within one week. After filling out the expense report the manager should approve the expense report. If the manager approves the expense report the money can be paid out by finance. If approval is awaiting manager approval payout cannot happen. If the manager rejects the expense report he must later approve the expense report in order to payout to happen. The employee can redraw the expense report. Doing so will close the case. Once payout has been done the case is closed and all activities are void.

Setting common authentication

The first thing to do is to set authentication for your Postman project.

Click to set authentication

Fillout userid and password of your DCR account:

User ID and password

Initialize simulation

The very first thing to do is to initialize the simulation, i.e. create an instance of the DCR process model. This is done using the InitializeInstance operation.

Initialize instance

Write down the X-DCR-Simulation-ID returned by the server, in the image 59443.

This is the ID of the simulation stored in DCR Active Repository and all URL's for getEvents, ExecuteEvents and setTime should be adjusted to host this id.

getEvents

Remember to adjust the URL using the simulation ID just returned from InitializeInstance.

getEvents - shown as XML

Remember to choose XML as format to view returned XML in an easy way.

ExecuteEvent - fill out expense report

Execute the Fill out expense report first.

Fill out expense report

Then execute getEvents operation again

getEvents - shown as XML

Notice that the instance now have a deadline, nextDeadline, found in the XML, and that the event Approve is now pending.

ExecuteEvent - Approve

Exeucte the Approve event

Approve event

Then execute getEvents operation again

after approval - getEvents - shown as XML

Compare with the getEvents above - now the Payout event is enabled and pending.

setTime

Note the nextDeadline time from getEvents above and try to execute setTime.

setTime

Then getEvents again

after setTime - getEvents - shown as XML

Finally - Payout and the process stops

Execute Payout event

Payout event

Then execute getEvents to see the status.

after Payout - getEvents - shown as XML

Notice that the process is not completed, as isAccepting is True.

Related Release notes

Release 7.0.0

  • Use AI to help business people create models
  • Easier to use, work with and document dynamic effects
  • More information in DCR Publisher

Related Videos

No related videos found.

Related Articles

No related articles found.
LinkedIn
Share