I am trying to make a wikidata query using WikidataR package for R. My query shoud have the following results :
for each item of a list of wikidata elements (such as Q124988842, Q125696676, Q130644039) get the property P189 (country of discovery)
I have written the script below:
library(WikidataR)
q_list <- c("Q124988842" ,"Q125696676", "Q130644039")
qid_list <- c(paste0("wd:",q_list, collapse = " "))
query_sparql <- paste0("SELECT
?item ?country
WHERE {", qid_list,"}
OPTIONAL { ?item wdt:P189 ?locationOfDiscovery. }
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en'. }
}")
print(query_sparql)
results <- query_wikidata(query_sparql)
print(results)
and get this error message:
Erreur dans FUN(X[[i]], ...) : Bad Request (HTTP 400).
What is going wrong?
I have tried to put all my QID in a list and then my insert my list inside the query, but the query seems to be invalid.