我想将以下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选项”。有什么想法吗?
答案 0 :(得分:3)
转到...
参数的任何内容都被解释为卷曲选项。您需要将参数作为列表放在httpheader
参数中。 See documentation
尝试类似:
getURL("https://api.example.com/resource",
userpwd ="username:password",
httpheader=list(param1="value",param2="value"))