ropensci / ckanr

R client for the CKAN API
https://docs.ropensci.org/ckanr
Other
99 stars 38 forks source link

ckan_info() not working with open.canada.ca #169

Closed nn-at closed 3 years ago

nn-at commented 3 years ago

Thank you for adding the Canadian Federal catalogue, https://open.canada.ca/en, to ckanr servers() #167

Unfortunately when I try ckan_info() with either URL listed in servers() (https://open.canada.ca/data and https://open.canada.ca/ckan) as well as other permutations I tested, I receive an error message:

"Error in xx[[2]] : subscript out of bounds"

However, I was able to receive a correct response within R using fromJSON:

fromJSON("https://open.canada.ca/data/api/action/status_show")

URLs tested https://open.canada.ca/data https://open.canada.ca/ckan https://open.canada.ca/ http://open.canada.ca https://search.open.canada.ca/ https://search.open.canada.ca/en/od/?search_text=
Traceback ```r traceback() 15: tolower(xx[[2]]) 14: stats::setNames(xx[[3]], tolower(xx[[2]])) 13: as.list(stats::setNames(xx[[3]], tolower(xx[[2]]))) 12: FUN(X[[i]], ...) 11: lapply(x, head_parse) 10: do.call("c", lapply(x, head_parse)) 9: FUN(X[[i]], ...) 8: lapply(curl::parse_headers(hh, multiple = TRUE), headers_parse) 7: private$make_request(rr) 6: verb_func(...) 5: con$verb(verb, query = query) 4: ckan_VERB("get", url, method, body = NULL, key, query, headers, opts, ...) 3: ckan_GET(url, "status_show", opts = list(...)) 2: jsonlite::fromJSON(ckan_GET(url, "status_show", opts = list(...))) 1: ckan_info(url = "https://open.canada.ca/ckan") ```
sckott commented 3 years ago

This is due to weird response headers returned - It's an issue in the http client crul - it's fixed in a dev version of crul https://github.com/ropensci/crul/issues/150 - install it like remotes::install_github("ropensci/crul")