K2 Integration with REST Api Services


We know that K2 has ability to integrate with multiple LOB’s, let us have a look at how we can integrate K2 with REST Api’s.

This post will explain you

  • How we create a REST Service Instance for a REST Api using K2 REST Service broker.
  • Create a Smart Object to get the data from REST Api.
  • Execute that Smart Object Method.

Creating REST Service Instance

K2 uses Swagger Definition of REST Service for creating a Service Instance. Swagger definition can be obtained by using an online Tool RESTUnited.com

RESTUnited.com is an online tool to generate the swagger definition of a service.

Now for this sample I have used the openWeatherMap.org which provides free REST API’s of weather information with multiple querying options for free along with some paid featured services too.

To Use their free services you need to register with your mail ID and some other basic details. Once registered, you would get an API Key which you need to use for all the API calls.

They have provided enough documentation of their wide range of API’s with details at below link



Here is a sample call to one of the REST Api which takes city name as input and gives the weather response. Please note that API key needs to be passed as URL Parameter APPID



Once you have Api ready, we need to get the swagger definition of that service. Now to get that use RESTUnited.com an online tool. You need to register here for a free trail to use the tool. Now follow the instructions as given at below link.


Once you have completed all the steps you will see below screen in which you would be able to download the Swagger definition by selecting Swagger Tab and clicking Export Button.


Once you have the Swagger Definition/Descriptor file,

  • Open SmartObjects – Services – Tester utility tool(find this utility at C:/Program Files/K2 Blackpearl/bin),
  • Expand ServiceObject Explorer right click on REST,
  • Click Register ServiceInstance and you will be seeing below screen where in highlighted area you need to give the path of that swagger file that we just downloaded.


  • Now Click Next button and you should see below screen and Click Add.



Now you should be able to see the Service Instance Added under the REST Category as below, you can explore the methods and types under it from here.


Creating Smart Object

Now it’s time to create a smart object using this Service Instance. We can use K2 Designer or Visual Studio or K2 Studio for creating but here I would prefer to use the same SmartObjects – Services – Tester utility tool to create as it’s the fastest way to create and publish an SMO.

Just give a right click on the object type or method that you want to use from Service Instance and Select Create SmartObject, now you would be seeing below screen. In that give you’re SmartObject a Name and select the folder under Category dropdown and Click Publish SmartObject


That’s it. Now navigate to your SMO and execute the method to see the results.

Below are the serialized data responses from the Api, now to get the individual Values, we need to deserialize them. For knowing how to deserialize the serialized responses check here Handling Complex Objects in K2 SmartObjects


This is how we can integrate K2 with REST Api Services .

Cheers Guys!!!

Author: Vijay

I'm a K2 Certified Developer, helping teams to automate, design, develop & maintain business process applications connecting across multiple platforms with multiple technologies.

8 thoughts on “K2 Integration with REST Api Services”

  1. Agree, it’s cool. I am using Rest Service Broker for things like Address Validation etc. It’s awesome. Recently I’ve been trying to create a list method from RestAPI since couple of weeks and I am hitting a dead end. Return a list object like list of Profile Details and see if you can deserialize it to a list method.


    1. I have left the serialized data as it is in this sample but the service instance has given the method for deserialize which would do the work for us. I’ll do it and add that screen grab for you, mean while what’s the issue that you are seeing at your end while deserializing..


    1. Hi, If you don’t have the swagger of the rest endpoint try generating the swagger file for the REST endpoint using editor.swagger.io or restUnited.com and use that swagger to register the service instance.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s