【问题标题】:setting query params to RESTful API with getURL in RCurl使用 RCurl 中的 getURL 将查询参数设置为 RESTful API
【发布时间】:2013-10-04 03:18:42
【问题描述】:

我想翻译以下 HTTP GET 命令以使用 RCurl:

curl -G https://api.example.com/resource \
-d "param=value" \
-d "param=value" \
-u 'user:password'

这是我在 RCurl 中使用 getURL 的尝试:

getURL("https://api.example.com/resource",
userpwd ="username:password",param="value",param="value")

第一个代码块在我的命令行终端中运行良好,在我尝试设置参数之前,我使用 getURL 没有任何问题;我收到警告消息说参数是“无法识别的 CURL 选项”。有什么想法吗?

【问题讨论】:

  • 发布了我的 RCurl 尝试。

标签: r get rcurl


【解决方案1】:

... 参数的任何内容都被解释为 curl 选项。您需要将参数作为列表放在httpheader 参数中。 See documentation.

尝试类似:

getURL("https://api.example.com/resource",
       userpwd ="username:password",
       httpheader=list(param1="value",param2="value"))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-11
    • 1970-01-01
    • 2015-10-08
    • 2019-04-18
    • 2020-12-24
    • 1970-01-01
    • 2015-09-07
    • 2012-12-21
    相关资源
    最近更新 更多