r - 如何通过 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 我如何找到丢失的部分?
解决方案
这有点棘手:
- 您需要使用正确的 url 和来自https://data.eppo.int/documentation/rest的服务名称,例如使用EPPOCodes 列表中的搜索首选名称:
url = "https://data.eppo.int/api/rest/1.0/tools/codes2prefnames"
- 授权应传递给主体:
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),这应该不是问题。
推荐阅读
- c++ - 取消引用的 unique_ptr 和更改 struct 中的值不会坚持
- amazon-web-services - SSM 参数允许的最大版本更改数
- sql - 创建自定义列
- haskell - 哪个是多态类型:一个类型还是一组类型?
- java - 覆盖默认 AutowiredAnnotationBeanPostProcessor 以停止 JSR-330 支持
- java - Hql 错误:类未映射,无法解析符号
- mql4 - 我在 ex4 中使用自定义指标编写了一个 EA
- python - 年度数据的两个数据框如何在年份之间找到
- salesforce - DocuSign 短信认证
- java - React Native:是否可以在应用重新加载时保留本机 Java 变量值?