API Information API Walkthrough

Report 10 Downloads 349 Views
Users API: Load Custom Data from Canvas Catalog

This document has been deprecated. To view custom data, please see the User Registration API in the Catalog API​ . Catalog customers can create custom user fields for their catalogs, and the information is stored in the user’s Canvas account. But how can that custom user information be viewed? Currently neither Canvas nor Catalog offer a way to access this data directly through either interface. The only option is through an application program interface (API). If you do not know how to use APIs, please contact your Canvas Catalog admin/Canvas Customer Success Manager.

API Information Endpoint information and documentation can be found in the Users API: https://canvas.instructure.com/doc/api/users.html#method.custom_data.get_data To make an API call, the following information is required: User ID​ : The Canvas user ID ● Catalog ID​ : The Catalog root ID. Find this information in the Catalog admin interface and view the Reports page; use the ID of the first catalog in the list ●

API request: GET https://canvasaccount.instructure.com/api/v1/users/:user_id/custom_data/registration/:catalog_id

API Walkthrough If you don't already have the Canvas user ID, it can be found through another API call to Canvas: $ curl "https://canvasaccount.instructure.com/api/v1/accounts/self/users" \ -H 'Authorization: Bearer ' \ -F 'search_term='

For an API call using an administrator's API token, the​ search_term​ will look for a partial match on name or email address. Leaving out ​ search_term ​ will return a full list of users registered on your account. It will return a list of users looking similar to this: { "id": 22, "login_id": "[email protected]", "name": "John Doe" }

© Canvas 2016 | guides.canvaslms.com | updated 2015-07-20

Page 1

Users API: Load Custom Data from Canvas Catalog

The ID field represents the Canvas user ID you need for the next call. The root Catalog ID can be found by going into the Catalog admin interface and loading up the Reports page. Use the "Catalog ID" of the first catalog in the list. Your final API request should look like this: $ curl "​ https://canvasaccount.instructure.com/api/v1/users/:user_id/custom_data/registration/:catalog_id"​\ -H 'Authorization: Bearer ' \ -F 'ns=com.instructure.gallery'

Replace ​ :user_id​ with the Canvas user ID found above, and the :​ catalog_id​ with the root Catalog ID found in the reports. This will return all custom fields filled out by the user during registration in this format: { "data": { "user-defined-field-name": "Value Entered by User" } }

Note that when fields aren't required, and the user doesn't fill them out, they won't have a key or value in this request.

© Canvas 2016 | guides.canvaslms.com | updated 2015-07-20

Page 2