基本上,我想要获得以下curl调用的RCurl等价物:
curl -H "AUTH-KEY: soanclCNdnLDcnlNc" -H "Content-Type: application/json" -X POST -d '{"documents":["http://localhost:3000/documents/2","http://localhost:3000/documents/4"]}' http://localhost:3000/documents/download?format=zip
我设法从中获得了一些东西,但它总是比卷曲调用产生的更大,并且无法解压缩,并且不能在我的生活中发现它是什么。
x= list(items=c("http://localhost:3000/documents/2", "http://localhost:3000/documents4"))
headers <- list('AUTH-KEY' = "soanclCNdnLDcnlNc", 'Accept' = 'application/json', 'Content-Type' = 'application/json')
postForm("http://localhost:3000/documents/download?format=zip", .opts=list(postfields=toJSON(x), httpheader=headers))
答案 0 :(得分:3)
虽然现在有更高档的套餐,但RCurl仍然做得很好。
一般来说,重新映射到RCurl:
Sub ChangeLink()
Dim OldLink As String
Dim NewLink As String
Dim wks As Worksheet
Set wks = ThisWorkbook.Worksheets("aaa")
OldLink = "SPECIFY OLD HERE"
NewLink = wks.Range("A1").Value
ThisWorkbook.ChangeLink Name:=OldLink, NewName:=NewLink, Type:=xlExcelLinks
End Sub
(相应地调整标题和字段)
您使用:
curl -H "AUTH-KEY: xxxx" \
-H "Content-Type: "application/x-www-form-urlencoded" \
-d '{"key1": "value1","key2": "value2"}' \
"https://httpbin.org/post"
请注意hdr=c(Authorization="xxxx", `Content-Type`="application/x-www-form-urlencoded")
flds='{"key1": "value1","key2": "value2"}'
postForm("https://httpbin.org/post",
.opts=list(httpheader=hdr, postfields=flds))
的反引号以逃避减号。