K2 blackpearl

How to create a REST Service Instance for K2 v4.7 using Swagger

Slowly but surely the world is moving to Cloud-based solutions.  In K2’s latest version, SourceCode added the REST Service Broker to the SmartObject Services Tester tool.  So, how do you create a REST Service Instance in K2?


K2 Automated Testing Software

BenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.


BenchQA Logo


Free K2 Five Upgrade Review


The K2 REST Service Broker – at this moment – only works with Swagger.  You can find more information about Swagger here http://swagger.io/

In the Online Swagger Editor, you can create/edit or extend current Swagger API’s. The Swagger Editor also allows you to generate a server or clients.


1 - Online Swagger Editor

1 – Online Swagger Editor

To view your Web API Methods, you can use the Swagger UI online. Just browse to the Host inside your Swagger File.

2 - Swagger API Methods for K2

2 – Swagger API Methods for K2


The Swagger UI will show you the Methods (Get, Put, Post, Delete)

  • Get = Get Details (List Item)
  • Put = Update Item
  • Post = Create Item
  • Delete = Delete item

Once your API is ready, you can create the REST Service Instance in K2.  The REST Service Instance can be refreshed the same as other Service Instances from other K2 brokers.

3 - K2 Swagger Service Instance using SmartObject Tester

3 – K2 Swagger Service Instance using SmartObject Tester


Creating the Service Instance Requires the Descriptor location.  This location can be a JSON file in a directory or a hosted JSON file online. Just make sure that the Swagger version is at least v2.x.


4 - K2 Swagger Service Instance using SmartObject Tester

4 – K2 Swagger Service Instance using SmartObject Tester


You can select Next and add the desire System and Display name, then you can click on Add to finish the process.

The service instance will now be created.

If you expand the tree of the Service Instance in K2, you will find in the Object Types. The Object Types contain the properties of the specific data model, and the Method will contain all the operations of the Swagger API.

Next, create a SmartObject from a Swagger object type: right click on the Object Type and select Create SmartObject. Select methods and properties you want and publish your SmartObject.


5 - Create K2 SmartObject from Swagger Service

5 – Create K2 SmartObject from Swagger Service


Next, you can then execute the created SmartObject methods bound to the Swagger REST API.

Thats it!  Now you know how to create a K2 REST Service instance in K2 version 4.7


Need further technical advice or support?

Contact Us

You may also like

Please complete the below form and a member of the Velocity IT team will call you back.