I am trying make a POST request with data and header information using httr::POST. I can see how to make a POST request, but I am unable to get it to work with
httr::POST
You could try this; with content type and headers added:
link <- "http://www.my-api.com" df <- list(name="Fred", age="5") httr::POST(url = link, body = jsonlite::toJSON(df, pretty = T, auto_unbox = T), httr::add_headers(`accept` = 'application/json'), httr::content_type('application/json'))