Closed LTLA closed 1 year ago
httr has been superseded in favour of httr2, so is no longer under active development. If this problem is still important to you in httr2, I'd suggest filing an issue offer there 😄 (but httr2 generally does less munging of this sort so I doubt it's a problem). Thanks for using httr!
Some of the httr verbs call
body_config()
at some point, which in turn callscompact()
to remove length-zero elements. I'm guessing that this was originally intended to removeNULL
s, but it also removes empty vectors:I would have hoped for
foo
andstuff
to still be there, as they would be if I didjsonlite::toJSON
manually (below).I appreciate the automatic removal of the
NULL
bybody_config()
, but the current behavior is still problematic when an empty array is a legitimate value for my endpoint. The workaround is to manually removeNULL
s before JSON-ifying the body and settingencode="raw"
, but it took a fair amount of investigative work to nail down the issue in the first place.So, my questions are:
NULL
s are the concern, would it not be better to explicitly identify/remove them withis.null
inhttr:::is_empty()
?Session information
``` R version 4.1.0 Patched (2021-06-08 r80470) Platform: x86_64-apple-darwin19.6.0 (64-bit) Running under: macOS Catalina 10.15.7 Matrix products: default BLAS: /Users/luna/Software/R/R-4-1-branch-dev/lib/libRblas.dylib LAPACK: /Users/luna/Software/R/R-4-1-branch-dev/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] httr_1.4.2 BiocManager_1.30.16 compiler_4.1.0 [4] R6_2.5.1 tools_4.1.0 jsonlite_1.7.2 ```