Create a REST dataset
A REST Dataset makes a GET request to a REST API and turns each item in the response into a record. Processes and rules use it exactly like an OData dataset.
Before you start
Create and publish the Rest Data Source first, then create the dataset underneath it. Have the API's documentation to hand so you know the path, parameters and response shape.
Steps
-
Create the dataset
In the back office, open the menu on your Rest Data Source and create a REST Dataset.
-
Enter the Resource Path
In Resource Path, enter the part of the address after the data source's Base URL, such as
/sessions/completedor/users/$$UserId$$. Values put into the path by tokens are made safe for a web address automatically. -
Add Query Parameters
In Query Parameters, enter one
name=valueper line, for example:status=activeendDate[gt]={aoDynamicDays:-7}
Names are sent exactly as written, so bracket-style names such as
endDate[gt]work. Repeat a name on another line to send it more than once. Blank lines and lines starting with#are ignored, so you can use#for notes. -
Set the Items Path
In Items Path, enter where the list of items sits in the response, such as
dataorresults.items. Leave it empty if the response itself is the list. If the path points to a single object rather than a list, that object becomes one record. -
Set up pagination
If the API returns results a page at a time, choose a Pagination Mode and fill in the settings for it. Otherwise leave it as None.
-
Choose the fields
In Select, add a row per field, with a JSON path such as
user.emailand a friendly name in As. The list offers paths found in a sample of the API's response, and you can type a path that isn't listed. -
Save, publish and preview
Save and publish, then check the results on the dataset's Preview tab on the AutomatedOn site.
More detail
Messages you might see
- Items path '...' was not found in the response.: check the Items Path against a real response.
- Items path '...' points to a ... value; it must point to an array or object.: the path points at a single value rather than a list or object.
- Can't fetch a sample to list fields because the request uses ..., which only has a value at run time. Type the field path instead (e.g. user.userId or courses[*].code).: your path or parameters use a token that's only filled in when a process runs. Type the field paths yourself.
- The response from '...' was not valid JSON: ...: the API didn't return JSON. Check the path.