ckranr issue when accessing data.gov.mk

#1

Hi,

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 (data.gov.mk) 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.

2 Likes

#2

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

0 Likes

#3

Yes.

packageVersion("ckanr")
[1] ‘0.1.0’
1 Like

#4

Just for reproducible eg.

library(ckanr)
ckanr_setup("https://data.gov.mk/")
res = package_search()
package_show(res$results[[1]]$id)
#> 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 = "https://data.gov.mk/api/3/action/package_show"
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 https://github.com/ropensci/ckanr/issues/67

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

0 Likes

#5

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?

0 Likes

#6

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

opened an issue https://github.com/ropensci/ckanr/issues/109 to look into allowing the user to set the HTTP verb (get vs. post)

0 Likes