Celebrate Excellence in Education: Nominate Outstanding Educators by April 15!
Found this content helpful? Log in or sign up to leave a like!
New to Canvas. Working with powershell and the Canvas APIs. For a first shot I used the Users API to experiment with. Just listing users on our test sandbox. As I understand it, if I set the per_page to something less than the number of users I have, I should see the next, previous, and/or the last http: reference. I'm using the invoke-restmethod powershell cmdlet with a token specified. It returns users as it should. However when I try to find the links, I get nothing.
Tried displaying $jsondata.Links.count and I see zero. If I use the same uri in firefox with the RESTclient plugin, I see the links as i would expect. Any idea what's going on?
Bruce
Bruce,
It seems like the problem that you are encountering is that the link to the next page of resources is sent back in the header of the response, but the Powershell invoke-restmethod command only returns the body of the response. If you use invoke-webrequest instead, the object that get returned should also have the headers included. E.g.
$response = invoke-webrequest 'https://<canvas-base-uri>/api/v1/users'
$response.headers #this should show the link header (and others)
I hope this helps,
Alex
Great, I'll try that. Examples on MS site shows the invoke-rest method returning the link info in the headers! Can the web request handle passing the token in the headers?
Bruce
It looks like webrequest takes the same flags and arguments as restmethod, so you should be able to send headers the way you were before.
Sounds good, will give it a try, thanks!
Bruce
To participate in the Instructure Community, you need to sign up or log in:
Sign In