Pete42
New Member

Todo API returns blank/no results

Jump to solution

Hello,

I am working to make a sync script to pull Canvas Todos out from the API and return them.

If I log into Canvas and view my "To Do" section, there are several assignments, announcements, quizzes, etc listed. 

If I call the assignments API (/api/v1/courses/:course_id/assignments/), they are all returned.

However, calling the "todo" API (/api/v1/courses/:course_id/todo/) returns NO results (just a blank JSON [])

Is there a required parameter or something I have to send to request from the Todo API?

Does the API not return the same thing as what is displayed in the WebUI?

TIA

0 Kudos
1 Solution
James
Community Champion

@Pete42 

The todo and todo_item_count endpoints both work for me.

One scenario consistent with what you're seeing is that the API token you're using is for some user other than the one you're logged into Canvas as. 

Try "GET /users/self" to verify that you are using the correct token.

View solution in original post

0 Kudos
7 Replies
Pete42
New Member

The /api/v1/users/self/todo also returns blank/no results.

0 Kudos

In addition, calling "/api/v1/users/self/todo_item_count' returns the following:

{
"needs_grading_count": 0,
"assignments_needing_submitting": 0
}
 
That makes zero sense since there are dozens, if not hundreds, of assignments that need submitting.
0 Kudos
James
Community Champion

@Pete42 

The todo and todo_item_count endpoints both work for me.

One scenario consistent with what you're seeing is that the API token you're using is for some user other than the one you're logged into Canvas as. 

Try "GET /users/self" to verify that you are using the correct token.

0 Kudos

It looks like there must be something that had to finish synching, as when I polled that API endpoint today, it returned results. 

0 Kudos

Next question: It looks like when I dismiss a Todo from the WebUI (click the "X" on it), it disappears there, but is still returned through the webUI. Is that expected? 

Or am I just dealing with another delay in API sync to webUI?

0 Kudos
James
Community Champion

I know that some things are cached, but I do not know if the To Do list is one of those. I queried my To Do list through the API and got 4 items, which matched what was in my To Do list Canvas. Then I hit the X to delete on through the Web UI and within 2 seconds queried the API again. This time it returned 3 items. This is what is expected when something isn't cached because the API and the web interface pull from the same source -- and in many cases, the web interface uses the API to get the data.

Are you running your own instance of Canvas or are you hosted by Instructure? I'm using an Instructure-hosted Canvas instance, so I cannot speak to self-hosted instances and what is needed to make it responsive without a significant delay.

0 Kudos

Hmm, gotcha. I didn't see that, I continued to get the same thing via API for several hours. However, about 24 hours later, it was updated.

I'll keep testing, this seems to be limited to the todo API - the assignments doesn't have that issue.

I believe instance is cloud hosted by Instructure, not self-hosted.

0 Kudos