Open collinschwantes opened 3 weeks ago
License validation for zenodo deposits may be too permissive. In the example below, the metadata passes validation when creating a new client but fails with a 400 error when running deposit_new.
deposit_new
The Zenodo API describes a list of approved licenses. https://developers.zenodo.org/#licenses
library(deposits) dotenv::load_dot_env() iris_metadata metadata <- list ( title = "New Title", description = "This is the abstract", creator = list (list (name = "A. Person", orcid = "https://orcid.org/0000-0002-0872-9950"), list (name = "B. Person", orcid = "https://orcid.org/0000-0002-9882-941X")), subject = list(name = "hello",name = "world"), format = "dataset", created = "2024-08-01", license = "cc-by-9999" ) cli_test <- depositsClient$new ( service = "zenodo", sandbox = TRUE, metadata = metadata ) cli_test$deposit_new()
Using an approved license the deposit_new method works.
library(deposits) dotenv::load_dot_env() iris_metadata metadata <- list ( title = "New Title", description = "This is the abstract", creator = list (list (name = "A. Person", orcid = "https://orcid.org/0000-0002-0872-9950"), list (name = "B. Person", orcid = "https://orcid.org/0000-0002-9882-941X")), subject = list(name = "hello",name = "world"), format = "dataset", created = "2024-08-01", license = "cc-by-nc-sa-4.0" ) cli_test <- depositsClient$new ( service = "zenodo", sandbox = TRUE, metadata = metadata ) cli_test$deposit_new()
Quick and dirty function for querying the license api
#' Query Zenodo Licenses #' #' @param q Character. Text based query #' @param page Numeric. Page number of query results #' @param size Numeric. Number of results to return per page. There are 444 different #' licenses in Zenodo as of August 2024 #' @param .multi Character. See `httr2::req_url_query` #' #' @return Response object from `httr2::req_perform` #' @export #' #' @examples #' #' # look for creative commons licenses #' response <- query_zenodo_licenses(q = "creative commons",size = 444) #' #' # get the json body of the response #' license_list <- response |> httr::2resp_body_json() #' #' # get just the ids from the response #' license_list$hits$hits |> #' purrr::map(\(x) x$id) #' query_zenodo_licenses <- function( q=NA, page =NA, size =NA,.multi = "explode"){ base_url <- "https://zenodo.org/api/licenses" req <- httr2::request(base_url) params<- list(q = q, page = page, size = size) keep_params <- !is.na(params) print(params[keep_params]) req <- req |> req_url_query(!!!params[keep_params]) response <- req |> req_perform() return(response) }
Looks like there is already a list of accepted licenses from ~6 months ago - https://github.com/ropenscilabs/deposits/blob/main/inst/extdata/zenodo/zenodo_licenses.csv
License validation for zenodo deposits may be too permissive. In the example below, the metadata passes validation when creating a new client but fails with a 400 error when running
deposit_new
.The Zenodo API describes a list of approved licenses. https://developers.zenodo.org/#licenses
Using an approved license the
deposit_new
method works.Quick and dirty function for querying the license api