This tutorial will show you how to use Call REST Service function to get data (in this example it will be JSON) from external REST service. For this tutorial I will use service, which returns us currency exchange rate for different kind of currencies.
The end result looks like this:
1. Creating workflow
Create simple workflow with one action launch form and one string variable. Name this variable result.
2. Creating activity to set result
Go to the activities editor and add Set variable activity:
In the Variable section add lookup to the result variable which we create earlier, and as a New value add lookup to Call REST Service function. The result should look like this:
3. Call REST Service – Example of use
In this particular example we want to call REST service which returns exchange rate for different currencies based on EUR exchange rate. We need to complete function fields as below:
- Request URI: in this field you specify the address of a REST query
- Login and Password: if service which you want to call needs additional credentials specify them here
- Content Type: the content type which you wish to get/post from/in REST service (JSON or XML)
- Headers: additional HTTP headers if REST service requires them
- Method: a REST method which you want to use – GET, POST, PUT, PATCH, DELETE
- Encoding: specifies encoding of your REST request (UTF-8 is default)
- Post data: here you can write your own JSON or XML which you want to upload to the REST service
4. Deploy and run
Remember to deploy your workflow before leaving Datapolis workflow designer. Now you can check how everything works by starting the workflow and running the action.
You can also Download the workflow definition and load it to your designer.