Search code examples
rposthttr

Send POST request with body in R


Here I need to send POST request where I body: {"pipelineName":"some_pipeline"} and Content-Type:application/json. Here is what I did

library(httr)

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

it came back with status 400. What am I doing wrong?


Solution

  • Try this

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