在R for API中使用POST丢失参数

时间:2019-03-12 06:12:03

标签: r api post httr

我目前正在使用POST函数(软件包httr)向API提交一些文本以获取处理后的输出,我的代码编写如下。

url = "..."
client_id = "..."
client_secret = "..."
request_body = jsonlite::toJSON(list(src = c("吃饭")), pretty=TRUE, auto_unbox=TRUE)
secret = jsonlite::base64_enc(paste(client_id, client_secret, sep = ":"))
req = httr::POST(url, 
             httr::add_headers(
               "Authorization" = paste("Basic", gsub("\n", "", secret)),
               "Content-Type" = "application/json; charset=UTF-8"),
             body = request_body,verbose()
);
content(req)

然后我收到以下错误消息:

"missing parameters: {client_id, client_secret}"

有人知道我的代码或步骤有什么问题吗?非常感谢!

0 个答案:

没有答案