I want to upload a file to a web API. According to the documentation, I need to pass a POST request to an upload url, including a list of required upload parameters as well as the file.
The API is private, so I can't share a reproducible example, but I'm struggling to format the final POST request.
Attempt 1: Error: All components of body must be named
upload_content <- httr::content(upload_resp)
upload_url <- upload_content$upload_url
upload_params <- c(upload_content$upload_params, httr::upload_file(file_name))
httr::POST(upload_url, body = list(upload_params))
Attempt 2: Error: All components of body must be named
upload_content <- httr::content(upload_resp)
upload_url <- upload_content$upload_url
upload_params <- upload_content$upload_params
httr::POST(upload_url, body = list(upload_params, httr::upload_file(file_name)))
Attempt 3: Status 400: Bad Request
upload_content <- httr::content(upload_resp)
upload_url <- upload_content$upload_url
upload_params <- c(upload_content$upload_params, httr::upload_file(file_name))
httr::POST(upload_url, body = list(upload_params))
How do I append the file to the upload parameters? And how should I format the body of the POST request?