Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_announcements url is incorrect #70

Open
cmgray00 opened this issue Sep 28, 2024 · 1 comment
Open

get_announcements url is incorrect #70

cmgray00 opened this issue Sep 28, 2024 · 1 comment

Comments

@cmgray00
Copy link

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
}
@pachadotdev
Copy link
Collaborator

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
}

I am a bit jammed now, but I will add your function asap when I find the time to test it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants