在 R 中发送带有正文的 POST 请求

Send POST request with body in R

这里我需要发送 POST 请求,我正文:{"pipelineName":"some_pipeline"}Content-Type:application/json。这是我做的

library(httr)

res = POST("https://some_url",
             body = list(pipelineName ="some_pipeline"),
             add_headers(.headers = c("Content-Type"="application/json")))

返回状态为 400。我做错了什么?

试试这个

res <- POST("https://some_url", body = list(pipelineName ="some_pipeline"), encode = "json")