使用httr/R访问RapidAPI时出现问题-状态:401



我正试图使用R中的httr包访问RapidAPI,如下所示:

library(httr)
url <- "https://extract-news.p.rapidapi.com/v0/article"
queryString <- list(url = "https://www.theverge.com/2020/4/17/21224728/bill-gates-coronavirus-lies-5g-covid-19")
response <- VERB("GET", url, addheaders(x_rapidapi_key ="my-api-key", x_rapidapi_host = "extract-news.p.rapidapi.com"), query = queryString, contenttype("application/octet-stream"))
content(response, "text")

我也尝试过访问其他API。然而,我一直收到这个错误消息:

Status: 401 

你能帮我解决这个问题吗?提前感谢!

尝试使用content_type()add_headers而不是contenttypeaddheaders来告诉服务器您要发送的数据类型。点击此处了解有关VERB方法的更多信息。

library(httr)
url <- "https://extract-news.p.rapidapi.com/v0/article"
queryString <- list(url = "https://www.theverge.com/2020/4/17/21224728/bill-gates-coronavirus-lies-5g-covid-19")
response <- VERB("GET", url, add_headers(x_rapidapi-host = 'extract-news.p.rapidapi.com', x_rapidapi-key = '*************************', '), query = queryString, content_type("application/octet-stream"))
content(response, "text")

相关内容

  • 没有找到相关文章

最新更新