【发布时间】:2021-02-02 12:35:26
【问题描述】:
发布请求如下所示:
curl --location --request POST ''
--form 'ids=["ae8a1312","59569d79"]'
这里的 ids 需要在 post 请求中作为数组传递。尝试使用以下代码:
body <- list(
sweep_ids = ids
)
resp <- POST(url, body = body, encode = "form")
这里的变量ids 是id 列表。上面这段代码给出了以下错误
Warning: Error in vapply: values must be length 1,
but FUN(X[[1]]) result is length 2
不能将编码用作 JSON。
如何在 R 中将 id 列表传递给这个表单编码的 POST 请求?
【问题讨论】:
-
试试
POST(url, body = '{"a":"ae8a1312","b":"59569d79"}', encode = "raw")。还是不行?