Discover the options available for integration between K2 and UiPath, for both inbound and outbound communication that allows you to make calls from K2 (via SmartObjects) to start processes in UiPath and how make calls from UiPath interact with K2 forms and workflows.
In addition to the above requirements, you must have a basic understanding of REST-based web services, Swagger (OpenAPI), and Visual Basic (in UiPath Studio).
The OAuth flow that allows you to call the UiPath APIs requires a custom OAuth extension to get a valid authorization token due to the way in which UiPath implements their authorization. UiPath requires that you specify your tenancy name, user name, and password as part of the body of the request to their API. This is different than the user-based OAuth consent flow that K2 handles out-of-the-box.
Extract the contents of the download available with this article and locate the SoureCode.Security.OAuth.Extensions.UiPath.dll. Copy it to the following location on your K2 Five server:
<install drive>:\Program Files or Program Files (x86)\K2\Host Server\Bin\OAuth\Extensions
Use this step to add a new OAuth resource type.
Your new resource type looks similar to the following:
Step 3: Add Resource Type Parameters
You need to add parameters to the UiPath resource type.
For each parameter check the Token Request option, and then click OK.
Your parameters look similar to the following:
OAuth resources are instances of an OAuth resource type, and contain configuration values to provide authorization tokens for a system. For example, if you have two UiPath tenancies, you'd create two OAuth resources based on the type you created in step 2.
Your page looks similar to the following and K2 is configured to communicate with UiPath.
Use the following diagram and scenarios for discovering how to enable two-way communication between K2 and UiPath.
You typically use two main UiPath APIs, Queues and Jobs, in your K2 form or workflow. Use Queues to load a queue with work for a robot to process. Use Jobs to execute a process.
The name of the queue is defined in UiPath Orchestration. The name/value pairs that you need to send into the queue depend on how the UiPath process designer created it, so you'll need to know what these are before you can load a queue.
Use Jobs to start UiPath processes, which is different from how you start K2 processes/workflows. Loading a queue and starting a job is how you put a robot to work.
You call this API using an instance of the K2 REST service type, configured to use the UiPath OAuth resource and the attached Swagger descriptor.
You use the Add_Queue_Item method of the QueueItemResponse SmartObject to add items to the queue, and the StartJobs SmartObject to start a UiPath process. For more information about working with complex types, see Working with Endpoint SmartObjects: Serialization and Deserialization. A Postman collection of the API calls is available for download to help you understand the requirements of the UiPath APIs and help test your solution.
Once you have your SmartObjects and you know how to use their methods, you can use these SmartObjects in SmartForms and workflow SmartObject events to integrate with UiPath.
UiPath provides activities for working with REST-based services, including the K2 Workflow REST API which you can use to start and action K2 workflows from UiPath. To get started, make sure that UiPath Studio has the additional components installed to work with REST-based services. Once installed they can be found in the Activities library under Available > App Integration > Web > HTTP Request as pictured here:
If you do not see the App Integration section, you may need to click the Refresh button to force the Activities panel to reload the available wizards, or you may need to install the UiPath.Web.Activities package. To check to see if your installation of UiPath has the package installed, click the package icon on the activities panel and look for UiPath.Web.Activities in the list. If it isn’t there, you can search and install it from the following window:
You need the following UiPath activities to call the K2 Workflow REST API:
Once you configure this, HttpClient activity appears on the UiPath process canvas. Select the activity and, in the Properties panel, set the value of the body property to the UiPath variable where you stored the request body you created using the Invoke Code activity. In this example, the JSON request is contained in a UiPath variable called K2Request.
Once the K2 workflow is started, UiPath requires that you update the queue item transaction status so that future execution of the job doesn’t attempt to process the same queue item again.
The K2Example UiPath Process is provided for reference in the article download.
Use the following resources to learn more about UiPath: