Instant Estimate +44(0)1908738254
YOUR EXPERT RPA PARTNER

Team up with our RPA strategy and tech specialists for maximum automation impact

Find out more
Harness the power of UiPath in your business.
WATCH NOW

Save money and spend more time on priority work.

Book consultation
READY, SET, AUTOMATE

Let's choose, design and deploy a process automation solution for your business.

Find out more
TRANSFORM YOUR BUSINESS

Let's analyse your business to discover opportunities for innovation and automation.

Find out more

Begin your business transformation journey

Book consultation
AUTOMATE EVERY FUNCTION

Automate where it matters most. Scale to solve challenges in every area

Find out more
GIVE EVERY TEAM THE TOOLS FOR SUCCESS

Equip people with user-friendly solutions that save time and make work easier

Find out more

Which business problem
can we solve first?

Book consultation
16 October 2016

Example Custom JSON K2 Service Broker

Several people asked me how to implement a custom JSON Service Broker for K2.  There are a few examples out there, but this is a quick reference that will get you up and running.

The first step is to create a custom K2 Service Broker. To create a basic service broker, follow the steps in the previous blog post – “How to create a custom service broker”

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.

 

Free K2 Five Upgrade Review

Then, follow the steps below to implement the K2 JSON Service Broker that allows us to read JSON data and display it in a K2 SmartForm.

Step 1: Create a List Method.

After you created your custom K2 Service Broker as described in the blog post mentioned above, implement your List method:

1-list-method

1-List method

Step 2: Create the request to the URL.

Here we send the request to the web service to get the JSON data back.

2-web-request

2- Web Request

The URL would be the web service URL that contains the JSON data. After getting the JSON data back, we need to deserialize it into an object.

Step 3: Deserialize the JSON object into a Root Class.

Because we know how the object looks like – we created a class for the JSON data- we can handle the data better and increase the performance of the List method.

3-deserialized

3-Deserialized

Step 4: Iterate through the JSON list data.

After deserialising the object, iterate through the RootContract.Contracts and set the JSON data to the K2 Service Broker’s properties.

4-iterate-through-objects

4-Iterate through objects

Here is a full example of the code when we deserialize the object and iterating through them.

5-full-code

5-Full code sample

Need further technical advice or support?