scottquach/Canvas-Assignments-Transfer-For-Todoist

Error executing

Closed this issue ยท 10 comments

Hello!

I found this project and was very excited to be able to pull in my existing Canvas tasks to todoist. Unfortunately, it doesn't seem to work, and I'd love some help.

Executing it returns the error "AttributeError: 'str' object has no attribute 'get'"

`
user@macbookf Canvas-Assignments-Transfer-For-Todoist-master-1 % python easy_run.py
###################################################

Canvas-Assignments-Transfer-For-Todoist

###################################################

Traceback (most recent call last):
File "/Canvas-Assignments-Transfer-For-Todoist-master-1/easy_run.py", line 162, in
main()
File "/Canvas-Assignments-Transfer-For-Todoist-master-1/easy_run.py", line 22, in main
select_courses(keys)
File โ€œ/Canvas-Assignments-Transfer-For-Todoist-master-1/easy_run.py", line 73, in select_courses
courses_id_name_dict[course.get('id', None)] = course.get('name', None)
AttributeError: 'str' object has no attribute 'get'`

I also found and identified a few additional notes/problems:

  1. Many universities appear to have custom domain hosted Canvas URLs - so I needed to change the URL from "https://canvas.instructure.com" to the URL of my university
  2. To obtain an API key, you go to "Account" then "Settings", then "New Access Token"
  3. I've confirmed the canvas API does work and returns my classes successfully (happy to send privately if that would help)

It appears there is some sort of change with API authentication - adding the response or response.status_code returns a 401 for me. Will troubleshoot that further.

Sorry to hear you are having problems, I've graduated from university so I haven't checked on this project in a while but will redownload and check it out. lukew3 also has a great fork of this project that may have more up to date specs https://github.com/lukew3/canvasTodoist

If you figure out the issue feel free to submit a pull request and I'll review it asap!

I just gave lukew3's a shot and had same issues, but it does appear more recent.

Manually modifying canvas_token to my API token allows the retrieve_canvas_course_ids.py to function successfully, but then I still get the same errors.

Okay, I found the issue, it appears that the tokens are not being stored in the right order. in api_keys.txt the canvas token should be the second line but is being stored as the first, meaning the Todoist token is being used for the canvas API.

Try manually switching the places in the api_keys.txt file to ensure this order.

Yeah, I got that far and figured that part out. Still something going on after that point. Here's what I get:

`user@mbp Canvas-Assignments-Transfer-For-Todoist-master-1 % python3 ./canvas_to_todoist.py

BA 140-02 Tableau for Business Analytics: 29740000000010544
BA 147-02 Intro to Databases and SQL: 29740000000011504
Traceback (most recent call last):
File "/Canvas-Assignments-Transfer-For-Todoist-master-1/./canvas_to_todoist.py", line 105, in
create_todoist_projects()
File "/Canvas-Assignments-Transfer-For-Todoist-master-1/./canvas_to_todoist.py", line 60, in create_todoist_projects
if courses_id_name_dict[course_id] not in todoist_project_dict:
KeyError: 10544
`

Were you able to get to the part where you select your courses and the ids get stored in api_keys.txt? After fixing the API key issues I was able to get it run and add assignments to my Todoist account.

Just re-tested, it works. Huge thanks for the quick response!

Glad it still somewhat works ๐Ÿ˜…

Feel free to submit a pull request for additional features/tweaks!

Also, it doesn't look like after testing that the custom URL is needed - the regular canvas.instructure.com URL appears to return the necessary data.

I did identify an additional bug issue when dealing with classes which have special characters in the title and started a separate thread for that.

There's also some other features I'd love to add, I'll try to get back to those.