Skip to content

Opt out of escaping for multi-value parameters #404

@asadow

Description

@asadow

Is it possible to opt out of escaping when supplying a vector to ... in req_url_query()?

library(httr2)
x <- c("[]PCO", "[]DM")
req <- request("w") 
req |> req_url_query(x = x, .multi = "comma")
#> <httr2_request>
#> GET /w?x=%5B%5DPCO,%5B%5DDM
#> Body: empty
req |> req_url_query(x = I(x), .multi = "comma")
#> Error in `lapply()`:
#> ! Escaped query value must be a single string, not a character vector.
#> Backtrace:
#>     ▆
#>  1. └─httr2::req_url_query(req, x = I(x), .multi = "comma")
#>  2.   └─httr2:::multi_dots(..., .multi = .multi)
#>  3.     └─base::lapply(X = dots[n > 1], FUN = format_query_param)
#>  4.       └─httr2 (local) FUN(X[[i]], ...)
#>  5.         └─httr2:::check_string(x, call = error_call, arg = I("Escaped query value"))
#>  6.           └─httr2:::stop_input_type(...)
#>  7.             └─rlang::abort(message, ..., call = call, arg = arg)

Created on 2023-11-30 with reprex v2.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions