daranzolin / rcanvas

R Client for Canvas LMS API
Other
90 stars 43 forks source link

create_course_assigment() returns "Bad Request" error #27

Closed scottkosty closed 6 years ago

scottkosty commented 6 years ago

Thanks for this great package! I'm a new user, so I might have just used the function incorrectly. Note that get_course_list() works well, so I think I have things set up correctly.

Here was my call to create_course_assigment():

> desc_ <- "HMC 8th edition exercises: 1.2.1, 1.2.2, 1.2.4, 1.2.6, 1.2.7, 1.2.8, 1.2.9, 1.2.14. 1.3.10, 1.3.12, 1.3.15, 1.3.21. If you have the 7th edition, do these exercises instead: 1.2.1, 1.2.2, 1.2.4, 1.2.8, 1.2.9, 1.2.10, 1.2.11, 1.2.16, 1.3.10, 13.12, 1.3.15, 1.3.20."
> create_course_assigment(course_id = 357998, name = "PS1",
+                          # change if online assignment
+                          submission_types = "on_paper",
+                          points_possible = 100,
+                          due_at = "2018-09-10T16:05",
+                          description = desc_,
+ )
Error in canvas_query(url, args, "POST") : Bad Request (HTTP 400).

Can you reproduce?

daranzolin commented 6 years ago

Looks like you need to reformat the due_at argument. This works for me:

desc_ <- "HMC 8th edition exercises: 1.2.1, 1.2.2, 1.2.4, 1.2.6, 1.2.7, 1.2.8, 1.2.9, 1.2.14. 1.3.10, 1.3.12, 1.3.15, 1.3.21. If you have the 7th edition, do these exercises instead: 1.2.1, 1.2.2, 1.2.4, 1.2.8, 1.2.9, 1.2.10, 1.2.11, 1.2.16, 1.3.10, 13.12, 1.3.15, 1.3.20."
create_course_assigment(course_id = 1320586, name = "PS1",
                                                    # change if online assignment
                                                      submission_types = "on_paper",
                                                    points_possible = 100,
                                                    due_at = "2018-09-10T16:05:00Z",
                                                    description = desc_
                           )

Also, I cannot believe there's a typo in this function. Ugh! How embarrassing.

scottkosty commented 6 years ago

@daranzolin thanks for taking a look at that! I'll test out your fix for my next assignment.

Also, I cannot believe there's a typo in this function.

I'd be happy to make a pull request that fixes this. Let me know.

daranzolin commented 6 years ago

@scottkosty pull requests are always welcome!

scottkosty commented 6 years ago

@daranzolin done!