nealrichardson / httptest2

Utilities for testing R 📦s that use httr2
https://enpiar.com/httptest2/
Other
26 stars 6 forks source link

Requests with multipart body containing character values fail #39

Closed jmaspons closed 2 weeks ago

jmaspons commented 2 months ago

Character values should also be accepted (see the last example in https://httr2.r-lib.org/reference/req_body.html) but they fail in httptest2:

library(httr2)
library(httptest2)

path <- tempfile()
writeLines(letters[1:3], path)

req <- request(example_url()) |>
  req_url_path("/post") |>
  req_body_multipart(file = curl::form_file(path), char = "some text", form = curl::form_data("data"))
# req_dry_run(req)
capture_requests(req_perform(req))
#> Error in x$value: $ operator is invalid for atomic vectors

It works removing the char = "some text" part.