ckranr issue when accessing


I’m not sure if this is the right place to ask this question but here it goes.

I’m trying to access a ckan portal ( using ckanr. I’m just following the tutorial. Every time I try to package_show it returns an error:

Error: 400 - Bad Request (HTTP 400).
  "\u041b\u043e\u0448\u043e \u0431\u0430\u0440\u0430\u045a\u0435 - JSON \u0433\u0440\u0435\u0448\u043a\u0430: Invalid request. Please use POST method for your request"

My R version is 3.5.3 (2019-03-11).

I’m not sure if there is anything else I should report. I don’t know if this is a ckanr issue or something is messed up with the ckan portal. Any insight would be helpful. Thanks.


thanks for your question @novica - can you share what version of ckanr you’re using


[1] ‘0.1.0’
1 Like

Just for reproducible eg.

res = package_search()
#> Error: 400 - Bad Request (HTTP 400).
#>   "\u041b\u043e\u0448\u043e \u0431\u0430\u0440\u0430\u045a\u0435 - JSON \u0433\u0440\u0435\u0448\u043a\u0430: Invalid request. Please use POST method for your request"

Internally, package_show is doing a GET request.

A POST request does work

url = ""
body = list(id = "30e85cc1-db68-44e6-a266-a263eb7f19a5")
res <- POST(url, body=body, encode="json", content_type_json())

we did have POST requests in the package for many fxns but changed them mostly to GET requests a while back because many CKAN instances blocked all POST requests

Not sure what to do here. We could allow the user to choose GET or POST http method

To be honest I am new at ckan/r and not entirely sure what is going on. Is it possible that they somehow misconfigured the ckan portal and it requires POST instead of GET?

possible. I don’t think it’s wrong per se, but it may be uncommon relative to other CKAN instances.

opened an issue to look into allowing the user to set the HTTP verb (get vs. post)

Providing an api key seems to be solving the issue with the bad request error.

nice, glad you figured it out

Just to refresh this thread. It seems whatever was working with doesn’t work anymore. The site no longer has https, and I suspect the api key is not being posted properly resulting in the same error as before.

This is on ckanr 0.4.0

thanks for pinging us again here.

If you reinstall remotes::install_github("ropensci/ckanr"), restart the R session, it should work now. you need to use http instead of https, and use http_method = "POST"

res = package_search()
package_show(res$results[[1]]$id, http_method = "POST")