cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
d_cutting
Community Participant

Assignment List and Details via API

Jump to solution

Hi,

Very new to Canvas so this could just be me being less-than-gifted but using the API, I have a course and wish to get a student list and also the assignments from it. I am an instructor for this course and using my access token.

The course ID within Canvas is 1117 and we have both a live and a test environment, all hosted by Instructure on AWS.

When I make the API call to courses/1117 I get the course object back no problem.

When I call courses/1117/users with the option to get students again it comes back fine as paginated JSON.

However - a call to courses/1117/assignments returns a block of HTML with the title "Page Not Found" (it does this in both our test and live environments).

In the web interface I can click on one of the assignments and see that it has the ID 8155 so I then tried requesting courses/1117/assignments/8155.

This time I get JSON back, on live it says "the specified resource does not exist" and on test "user authentication required" (I'm passing a valid token in the URI and the same one works for all the calls above).

So:

Am I being stupid or should courses/:course_id/assignments work?

Shouldn't it return a JSON error rather than an HTML error page if it didn't?

And can anyone shed any light on the differences in return from the test and live environments?

Many thanks in advance!

Dave

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
d_cutting
Community Participant

Thanks Jeffrey - really I should have tried the browser (doh!). When I did I got valid JSON so I dug into the test and turns out had a very old version of Postman and an errant & was appearing in the failing URIs when generated route&?x=y so no parameters were being passed.

Updated and working well now, slowly beginning my Canvas API journey.

Thanks!

View solution in original post

2 Replies
themidiman
Community Champion

Out of curiosity, what shows up in your web browser if you are logged into the course as instructor or admin type in the full URL of https : // <yourcanvasdomain> /api/v1/courses/1117/assignments ?

It should spit back the JSON to your browser prepended with while(1);

My other curiosity is if you are using a user API token in your API call URL as per the documentation? If so what's the code you are using to get perform the GET request to read the JSON data?

d_cutting
Community Participant

Thanks Jeffrey - really I should have tried the browser (doh!). When I did I got valid JSON so I dug into the test and turns out had a very old version of Postman and an errant & was appearing in the failing URIs when generated route&?x=y so no parameters were being passed.

Updated and working well now, slowly beginning my Canvas API journey.

Thanks!

View solution in original post