首页 > 解决方案 > 如何通过 POST 检索 EPPO 数据库信息?

问题描述

我可以从 GET 请求中检索EPPO DB信息。我正在寻求帮助以从 POST 请求中检索信息。 链接的 Rmarkdown HTMP 输出中的示例代码和其他信息

正如建议的那样,我已经浏览了https://httr.r-lib.org/网站。
有趣的。我点击链接到https://httr.r-lib.org/articles/api-packages.html然后到https://cdn.zapier.com/storage/learn_ebooks/e06a35cfcf092ec6dd22670383d9fd12.pdf。我想 POST() 函数的参数应该(或多或少)如下,但响应始终是 404

url = "https://data.eppo.int/api/rest/1.0/"
config = list(authtoken=my_authtoken)
body = list(intext = "Fraxinus anomala|Tobacco ringspot virus|invalide name|Sequoiadendron giganteum")
encode = "json"
#handle = ???

reprex 包(v0.3.0)创建于 2021-04-26 我如何找到丢失的部分?

标签: rpost

解决方案


这有点棘手:

  1. 您需要使用正确的 url 和来自https://data.eppo.int/documentation/rest的服务名称,例如使用EPPOCodes 列表中的搜索首选名称
    url = "https://data.eppo.int/api/rest/1.0/tools/codes2prefnames"
  1. 授权应传递给主体:
body = list(authtoken = "yourtoken", intext = "BEMITA")

因此,如果您想检查两个 eppocode 的名称:XYLEFA 和 BEMITA,代码应如下所示:

httr::POST(
  url = "https://data.eppo.int/api/rest/1.0/tools/codes2prefnames",
  body = list(authtoken = "yourtoken", intext = "BEMITA|XYLEFA") 
)

尽管如此,我也建议您只使用pestr包。但是,为了查找 eppocode,它在后台使用 SQLite 数据库而不是 EPPO REST API。由于数据库本身并不大(大约 40MB),这应该不是问题。


推荐阅读