Canvas Last Request by API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Anyone know an API endpoint that'll give the last request timestamp for a given users? We've found last login but need the last request that shows up on the user profile screen.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I understand you correctly. You want the last page view (any click) in Canvas from the API without having to do some looping?
Return a paginated list of the user's page view history in json format, similar to the available CSV download. Page views are returned in descending order, newest to oldest.
So, I think this is all you need.
/api/v1/users/self/page_views?per_page=1
The last record should be the last page view for any user.
fetch(`/api/v1/users/self/page_views?per_page=1`, {
'headers': {
'accept': 'application/json',
}
})
.then(r => r.json())
.then(r => console.log(r))
Now I'm getting mixed results, because when I run the request, I see the request as the last page view. So, if test with per_page=2, the second to last one shows a refresh of a page I want to see.
// (2) [{…}, {…}]
// 0:
// url: "/api/v1/users/self/page_views&per_page=1"
// ...
// created_at: "2020-04-21T23:46:14Z"
// updated_at: "2020-04-21T23:46:14Z"
// ...
// 1:
// url: "/courses/1234567/pages/module-0-orientation-overview?module_item_id=11181794"
// ...
// created_at: "2020-04-21T23:45:38Z"
// updated_at: "2020-04-21T23:45:38Z"
// ...
Sanity Check?
If I refresh x.instructure.com/accounts/self/users/self, showing me my own profile.
Then, run the API request for page_views, the last record from the API will be that.
Is that what you're looking for?