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
- Workflow - REST Generator
- Using the REST Generator in Workflow 7.6
- Using the REST Generator (GET) in Workflow 7.6 with Mobility Suite
- Using the REST Generator (Headers) in Workflow 7.6 with Mobility Suite
- Using the REST Generator (POST) in Workflow 7.6 with Mobility Suite
- Using the REST Generator (Response Content) in Workflow 7.6
- Using the REST Generator (PATHs) in Workflow 7.6
- Workflow - Read Write JSON
- Workflow - REST - Response Header
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 Postman [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"
Copy this Key as we will be using it soon.
Now go to your Workflow Server.
Open Workflow Manager.
File | New Project and create a new Forms (Web) Project.
Give this a name (POC_AppCenter_WEB).
In the Project Pane click on the top level Project 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)
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 Integration Project.
Give this a name (POC_REST_INT).
Scroll down to Enterprise Resources and choose the new REST Generator.
Give the Generator a name (AppCenter) and click OK.
Put in your variables:
Base URL: | https://#.appcenterhq.com/ |
---|---|
Namespace: | AppCenter |
* Replace # with your Tenant name
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.
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'
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.
It will then show the return.
It will then be selected as your Data Type.
Click on the 'Edit' to see the Data Types that have been created.
Finally click Finish.
OK the next screen then Recompile and Close.
(Add an Icon and any Description etc.)
Back to the sample Project.
Add this newly created Library.
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.
Double Click and add in your Parameters.
start=0&limit=100&api_key=[[ProjectProperties].api_key]
Add a Web Form and display the data.
Run the Form.
Follow up articles