r - 在 R 中发起 GET 请求

标签 r http rcurl httr

我一直在玩 httr 和 rcurl,但无法将以下 curl GET 请求转换为 R:

curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer 31232187asdsadh23187' 'https://this.url.api.com:334/api/endpoint'

特别是,我在传递授权选项时遇到了一些麻烦,因为我无法在两个库中找到等效参数。可能是自定义 header ?

最佳答案

httr::GET('https://this.url.api.com:334/api/endpoint', 
      accept_json(), 
      add_headers('Authorization' = 'Bearer 31232187asdsadh23187'))

另见 https://github.com/hrbrmstr/curlconverter

关于r - 在 R 中发起 GET 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35559913/

相关文章:

r - ggplot2如何在单个面上叠加标记?

r - 为插入符包中的多个列创建DataPartition

android - 如何解析以下格式的 HTTP 响应

通过 IO 设备处理请求的 HTTP 服务器?

Android 网络 - 最佳实践

r - RCurl 中的 TLS v1.1/TLS v1.2 支持

mysql - SQL Server 2008 R2 Express 行号

r - ggplot2 : label bar height 中的密度直方图

r - 使用 RCurl POST 请求

RCurl JSON 数据到 JIRA REST 添加问题