Using the REST Generator (GET) in Workflow 7.6 with Mobility Suite

Published on Wednesday, 6 May 2015

In this Article I will explain how to use the REST Generator within Workflow.

This builds upon a past article but shows using Parameters to make the component more flexible.

Follow up articles

I'm going to be using the RESTful APIs available in to us in the Mobility Suite.

To Test an APIs you could use a Chrome Plugin called PostmanLogo.pngPostman [http://www.getpostman.com/] or on a Mac there is an App you can get called Cocoa Rest Client [http://mmattozzi.github.io/cocoa-rest-client/]

Most APIs will require a Key to use them, make sure you have this to hand but don't share it.

We shall work with the Mobility API.

Login to your Tennant [#.appcenterhq.com/] [https://myappcenterh.appcenterhq.com/admin/landing]

Go to Admin Console. If you are in the App Store click on the top right hand link [Admin Console].

v5.2 - Settings | Mobility Manager configuration | APIs

**** (v5.1 Admin | Settings | APIs)

Click on the "Create New Access Key"

Data API.png

Copy this Key as we will be using it soon.

Now go to your Workflow Server.

Open Workflow.png Workflow Manager.

File | New Project and create a new Forms (Web).png Forms (Web) Project.

Give this a name (POC_AppCenter_WEB).

New Project - Forms (Web).png

In the Project Pane click on the top level Project Project.png POC_AppCenter_WEB

Go to the Properties tab and click Add Property, give it a 'name' of API_KEY with the 'value' of the key you copied before.

name API_KEY
value <your api key>

Encode this using either http://meyerweb.com/eric/tools/dencoder/ or in Fiddler [http://www.telerik.com/fiddler] Tools | Text Wizard... (Ctrl+E)

Project - Properties - Add Property.png

This will now be available to you in your Project.

(I like to make these as Profile Properties in Process Manager so they can be shared across Projects)

Choose an API you'd like to use. We shall get a list of Apps.

https://<tenant>.appcenterhq.com/api1/apps

Now that the Project is set up we can create the Generator.

Back in the main Workflow Manager window click on

File | New Project and create a new Int.png Integration Project.

Give this a name (POC_REST_INT).

New Project - Integration.png

Scroll down to Enterprise Resources and choose the new REST Generator.

Give the Generator a name (AppCenter) and click OK.

Create Generator_0.png

Put in your variables:

Base URL: https://#.appcenterhq.com/
Namespace: AppCenter

* Replace # with your Tenant name

1. REST Service URL_0.png

Click Next.

Now if we choose the API.

Add a NAME, choose your METHOD, and add the API.

Name Apps
Method GET
URL api1/apps?[urlparams]

You need to Save or click Next then Back to make the Properties available.

Click on Properties (along the Top)

Your urlparams will show. give it a Type and be sure to uncheck the URL Encode option.

2. Components.png

Now we want to configure the Response Content.

Click on the ellipse (...)

Choose JSON as the Format and click on 'Create' the 'Create From Request'

2. Components (1)_0.png

Put in your params

start=0&limit=100&api_key=##

*paste in your encoded api_key (we will use the Property later in the WF)

| **Warning!**Passing the API key as a query parameter is not recommended and is deprecated.

Support for passing the key via URL parameters will be removed in the near future. | | --- |

Click Next.

Request (1).png

It will then show the return.

Request (2).png

It will then be selected as your Data Type.

Response Content.png

Click on the 'Edit' to see the Data Types that have been created.

Data Types.png

Finally click Finish.

OK the next screen then Recompile and Close.

(Add an Icon and any Description etc.)

Help Editor.png

Back to the sample Project.

Add this newly created Library.

Project.png Project | Libraries | Add...

Select the dll, double click or click Add then click OK. (Untick Publish)

Find the Component and add it into your Workflow.

Workflow (1).png

Double Click and add in your Parameters.

start=0&limit=100&api_key=[[ProjectProperties].api_key]

Add a Web Form and display the data.

Workflow (2).png

Run the Form.

Workflow (3).png

Follow up articles

Protirus.png