How-To Execute a workflow from the swagger endpoint

Introduction

Whenever you are designing our testing a Next-Gen Workflow it might be useful to run the workflow with test data of your choosing. You certainly can execute the appropriate UI action to test the workflow, but it might be easier to do it manually as you can easily use any input data and any state you seem fitting. This document describes how to this.

Step 1: Get a token

In order to execute a workflow or any other action from the swagger endpoint, you will need an appropriate token. You can do this with any client that has access to the cos_workflow_api ressource, which you can request using the scope with the same name. An easy way to do this is in postman.

Step 2: Open up the swagger documentation

Open up the Workflow Swagger documentation. This documentation is available on the server where you have installed the workflow execution service and will look similar to the following url:

https://localhost:9001/swagger

Step 3: Paste the bearer token

Click on the Authorize button and past the access_token from step one into the field with a leading Bearer

Step 4: Find the appropriate endpoint

Depending on your use case, you have to find the appropriate endpoint. To simply start the execution of an existing workflow definition, you should use dispatch endpoint in the workflows section.

Step 5: Try it out

In order to be able to execute the endpoint from the swagger documentation you have to click on Try it out

Step 6: Find the appropriate workflow input

Each workflow definition is - implicitly - expecting input data. The excepted input data is documented in Next-Gen Workflows Available Workflow Entry Points. So if we were to execute a workflow definition that is registered to be executed after a user requested to reload a companies data from an external system we find the following documented input:

"Data": { id : uint, displayName : string, typeName : string, externalIdentifier: string }

Step 7: Add the workflow defininition id

Add the workflow definition id to the workflowDefinitionId parameter.

 

Step 8: Mary the workflow input data with the endpoint input data

Once you have clicked Try it out in Step 3, the request body section will show the default body for the request. That section will contain an input property where you have to add the content from the appropriate workflow documentation from Step 4.

The result should look like this:

{ "activityId": null, "correlationId": null, "contextId": null, "input": { "Data": { Id : 5450, DisplayName : "Beate Gielsdorf", TypeName : "iTsense.Moving.Backend.Services.DmcoreService.Adapters.NHibernate.Servicedmcore.OrganizationUnit", ExternalIdentifier: "CHE 367367116" }, "Context": { "CoreIdentityId": 3265, "UserId": 17177, "AppCustomerId": 900000 } } }

Step 9: Execute

Once you have configured the correct request body you can select the blue Execute button and if everything has worked you should receive a 200 result as shown below.

 

© ITSENSE AG. Alle Rechte vorbehalten. ITSENSE und CoreOne sind eingetragene Marken der ITSENSE AG.