Artisan IMG > Canvas (canvas) (00133065-7365-494b-9596-5a2e20006bc7)

Canvas
1.0

Canvas is a learning management platform.

Overview
Copy

Canvas is a learning management platform that allows educational institutions to manage administration, content and resources.

Authentication
Copy

When using the Canvas connector, the first thing you will need to do is go to your Tray.io account page, and select the workflow you wish to work on. Once in the workflow builder itself, search and drag the Canvas connector from the connectors panel (on the left hand side) onto your workflow.

With the new Canvas connector step highlighted, in the properties panel on the right, click on 'New Authentication' which is located under the 'Settings' heading.

This will result in a Tray.io authentication pop-up window. The first page will ask you to name your authentication, and state which type of authentication you wish to create ('Personal' or 'Organisational').

As you can see, the next page asks you for your 'Instance URL', 'Client ID' and 'Client secret'. This is required to go through the authentication flow.

Client ID and Secret can be obtained through either registering the OAuth app with Canvas for hosted canvas instance, or if hosting an open source canvas instance the ID and secret can be generate in the Site Admin account of the canvas install. See here for more information.

Also required at this point is to choose the scopes. Scopes required for operations that existing in the connector are listed. However, any additional scopes required for using the Raw HTTP Request with other endpoints are not and need to be specified.

Please see below that scopes url:GET|/api/v1/accounts and url:GET|/api/v1/accounts/:account_id/users have been specified.

Individual scopes are stated under each endpoint found in the Canvas API documentation.

When done click 'Create authentication' and the login window for Canvas will pop up. Enter the username/email and password of the user to authentication.

The next step will authorise the app specified by the client ID and secret to access this users data.

Go back to your settings authentication field (within the workflow builder properties panel), and select the recently added authentication from the dropdown options now available.

Your connector authentication setup should now be complete.

Available Operations
Copy

The examples below show one or two of the available connector operations in use.

Please see the Full Operations Reference at the end of this page for details on all available operations for this connector.

Note on Operations Usage
Copy

Pagination
Copy

Pagination is done by using links returned by a request to retrieve resources from Canvas e.g. a list of accounts.

The 'next' links needs to be passed into list operations to retrieve the next page of results. There are also links for first, last and current page if required.

For more information please refer to the Canvas API documentation Canvas Pagination section.

Using the Raw HTTP Request ('Universal Operation')
Copy

As of version 1.0, you can effectively create your own operations.

This is a very powerful feature which you can put to use when there is an endpoint in Canvas which is not used by any of our operations.

To use this you will first of all need to research the endpoint in the Canvas API documentation v1.0 , to find the exact format that Canvas will be expecting the endpoint to be passed in.

Note that you will only need to add the suffix to the endpoint, as the base URL will be automatically set (the base URL is picked up from the value you entered when you created your authentication).

The base URL for Canvas is your instance URL (which you enter when setting up the authentication) plus /api/v1.

For example if the instance URL was https://your-canvas-instance.com then full base URL would be: https://your-canvas-instance.com/api/v1.

Say that the 'List accounts' operation did not exist in our Canvas connector, and you wanted to use this endpoint, you would use the Canvas API docs to find the relevant endpoint - which in this case is a GET request called: /accounts.

As you can see there is also the option to include a query parameter, should you wish to do so. So if you know what your method, endpoint and details of your query parameters are, you can get the additional account information with the following settings:

Method: GET

Endpoint: /accounts

Query Parameter: Key: include[] Value: services

Body Type : None

Final Example outcome being: https://your-canvas-instance/api/v1/accounts?include[]=services

Example Usage
Copy

TRAY POTENTIAL: Tray.io is extremely flexible. By design there is no fixed way of working with it - you can pull whatever data you need from other services and work with it using our core and helper connectors. This demo which follows shows only one possible way of working with Tray.io and the Canvas connector. Once you've finished working through this example please see our Introduction to working with data and jsonpaths page and Data Guide for more details.

Below is an example of a way in which you could potentially use the Canvas connector, to list accounts and then create a user on each account.

The steps will be as follows:

  1. Setup using a manual trigger and add Canvas connector step

  2. Add loop connector

  3. Create new user

The final outcome should look like this:

1 - Setup Trigger & add first Canvas step
Copy

Once you have clicked 'Create new workflow' from your main Tray.io dashboard named it, select the Manual trigger from the trigger options available:

After you have been redirected to the Tray.io workflow dashboard, from the connectors panel on the left, add a Canvas connector to your second step. Set the operation to 'List accounts'.

Feel free to re-name your steps as you go along to make things clearer for yourself and other users.

This step will 10 accounts in the Canvas instance authenticated against. Also returned in output are the pagination links.

2 - Loop over account list
Copy

Next, search for the 'Loop collection' connector within your connector panel, and drag it into your workflow as your next step. Set your operations to 'Loop list'.

The Loop Collection connector allows you to iterate through a list of results. In this example, we will use it to iterate through the data found within the previous Canvas list accounts connector step.

In order to specify the list you want to loop through, start by using the 'List' mapping icon (found next to the list input field, within the properties panel) to generate the connector-snake.

While hovering over the 'canvas-1 List accounts' step (with the tail end of the connector-snake), select results from the list of output properties displayed. This will auto-populate a jsonpath within your 'List' input field, and update the type selector to jsonpath.

For more clarification on the pathways you have available, open the Debug panel to view your step's Input and Output.

JSONPATHS: For more information on what jsonpaths are and how to use jsonpaths with Tray, please see our pages on Basic data concepts and Mapping data between steps

CONNECTOR-SNAKE: The simplest and easiest way to generate your jsonpaths is to use our feature called the Connector-snake. Please see the main page for more details.

The workflow will now loop over the list of accounts, enabling steps to be executed for each account.

3 - Create new user
Copy

Using a jsonpath (put between curly braces) allows us to insert the ID from each account into the endpoint field.

INTERPOLATION: When you wish to include JSON generated data within another input/output result, use our Interpolation method as described here.

This will create a user on the account.