rcanvas icon indicating copy to clipboard operation
rcanvas copied to clipboard

get_announcements url is incorrect

Open cmgray00 opened this issue 4 months ago • 1 comments

Hello!

A simple fix is required to the get_announcements function.

Currently, the url is created per: url <- paste0(canvas_url(), "announcements")

This however, lacks a "/" before "announcements", causing a 404 not found error.

A workaround is to create your own function with the adjustment:

 get_announcements2 <- function(course_id, start_date = NULL, end_date = NULL,
                              active_only = FALSE) {
  if (!grepl(pattern = "course", x = course_id)) {
    course_id <- paste0("course_", course_id)
  }
  url <- paste0(rcanvas:::canvas_url(),"/", "announcements") # the added slash is the fix
  args <- list(per_page = 100)
  include <- rcanvas:::iter_args_list(course_id, "context_codes[]")
  include2 <- rcanvas:::iter_args_list(start_date, "start_date")
  include3 <- rcanvas:::iter_args_list(end_date, "end_date")
  args <- c(args, include, include2, include3)
  dat <- rcanvas:::process_response(url, args)
  dat
}

cmgray00 avatar Sep 28 '24 18:09 cmgray00