Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling POST from C# code does not process body correctly #915

Closed
MJSchut opened this issue Aug 24, 2023 · 2 comments · Fixed by #924
Closed

Calling POST from C# code does not process body correctly #915

MJSchut opened this issue Aug 24, 2023 · 2 comments · Fixed by #924

Comments

@MJSchut
Copy link

MJSchut commented Aug 24, 2023

System details

Output of sessioninfo::session_info()():

> sessioninfo::session_info()
- Session info -----------------------------------------------------------------------------------------------------------------------------------------
 setting  value
 version  R version 3.6.3 (2020-02-29)
 os       Windows 10 x64 (build 19044)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.1252
 ctype    English_United States.1252
 tz       Europe/Berlin
 date     2023-08-24
 rstudio  2023.06.1+524 Mountain Hydrangea (desktop)
 pandoc   3.1.1 @ C:/Users/Martijn.Schut/AppData/Local/Programs/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)

- Packages ---------------------------------------------------------------------------------------------------------------------------------------------
 ! package       * version  date (UTC) lib source
 1 abind           1.4-5    2016-07-21 [1] RSPM (R 3.6.3)
 1 alluvial      * 0.1-2    2016-09-09 [1] RSPM (R 3.6.2)
 1 anytime       * 0.3.9    2020-08-27 [1] RSPM (R 3.6.3)
 1 arrow         * 9.0.0    2022-08-10 [1] RSPM (R 3.6.3)
 1 askpass         1.1      2019-01-13 [1] RSPM (R 3.6.3)
 1 assertthat      0.2.1    2019-03-21 [1] RSPM (R 3.6.3)
 1 automap       * 1.0-16   2022-04-05 [1] RSPM (R 3.6.3)
 1 AzureAuth     * 1.3.3    2021-09-13 [1] RSPM (R 3.6.3)
 1 AzureGraph      1.3.2    2021-11-28 [1] RSPM (R 3.6.3)
 1 AzureRMR        2.4.3    2021-10-23 [1] RSPM (R 3.6.3)
 1 AzureStor     * 3.7.0    2022-05-25 [1] RSPM (R 3.6.3)
 1 backports       1.4.1    2021-12-13 [1] RSPM (R 3.6.3)
 1 base64enc       0.1-3    2015-07-28 [1] CRAN (R 3.6.3)
 1 BBmisc          1.13     2022-09-29 [1] RSPM (R 3.6.3)
 1 bit             4.0.5    2022-11-15 [1] RSPM (R 3.6.3)
 1 bit64           4.0.5    2020-08-30 [1] RSPM (R 3.6.3)
 1 boot            1.3-24   2019-12-20 [2] CRAN (R 3.6.3)
 1 Boruta        * 8.0.0    2022-11-12 [1] RSPM (R 3.6.3)
 1 broom           1.0.3    2023-01-25 [1] RSPM (R 3.6.3)
 1 bslib           0.4.2    2022-12-16 [1] RSPM (R 3.6.3)
 1 cachem          1.0.6    2021-08-19 [1] CRAN (R 3.6.3)
 1 cellranger      1.1.0    2016-07-27 [1] RSPM (R 3.6.3)
 1 checkmate     * 2.1.0    2022-04-21 [1] RSPM (R 3.6.3)
 1 checkpoint      1.0.2    2022-01-28 [2] RSPM (R 3.6.3)
 1 class           7.3-15   2019-01-01 [2] CRAN (R 3.6.3)
 1 cli             3.6.0    2023-01-09 [1] RSPM (R 3.6.3)
 1 cluster       * 2.1.4    2022-08-22 [1] RSPM (R 3.6.3)
 1 codetools       0.2-16   2018-12-24 [2] CRAN (R 3.6.3)
 1 colorspace      2.1-0    2023-01-23 [1] RSPM (R 3.6.3)
 1 colourpicker  * 1.2.0    2022-10-28 [1] RSPM (R 3.6.3)
 1 combinat        0.0-8    2012-10-29 [1] RSPM (R 3.6.3)
 1 conf.design   * 2.0.0    2013-02-23 [1] RSPM (R 3.6.2)
 1 corrplot      * 0.92     2021-11-18 [1] RSPM (R 3.6.3)
 1 crosstalk       1.2.0    2021-11-04 [1] RSPM (R 3.6.3)
 1 curl          * 5.0.0    2023-01-12 [1] RSPM (R 3.6.3)
 1 DALEX         * 2.4.3    2023-01-15 [1] RSPM (R 3.6.3)
 1 data.table    * 1.14.6   2022-11-16 [1] RSPM (R 3.6.3)
 1 dbscan        * 1.1-11   2022-10-27 [1] RSPM (R 3.6.3)
 1 digest          0.6.31   2022-12-11 [1] CRAN (R 3.6.3)
 1 DoE.base      * 1.2-1    2022-05-09 [1] RSPM (R 3.6.3)
 1 dplyr         * 1.1.0    2023-01-29 [1] RSPM (R 3.6.3)
 1 DT            * 0.27     2023-01-17 [1] RSPM (R 3.6.3)
 1 e1071         * 1.7-12   2022-10-24 [1] RSPM (R 3.6.3)
 1 ellipsis        0.3.2    2021-04-29 [1] CRAN (R 3.6.3)
 1 emoa          * 0.5-0.1  2020-03-06 [1] RSPM (R 3.6.3)
 1 EnvStats      * 2.7.0    2022-03-07 [1] RSPM (R 3.6.3)
 1 evaluate        0.20     2023-01-17 [1] RSPM (R 3.6.3)
 1 fansi           1.0.4    2023-01-22 [1] CRAN (R 3.6.3)
 1 farver          2.1.1    2022-07-06 [1] RSPM (R 3.6.3)
 1 fastmap         1.1.0    2021-01-25 [1] CRAN (R 3.6.3)
 1 fastmatch       1.1-3    2021-07-23 [1] RSPM (R 3.6.3)
 1 fastshap      * 0.0.7    2021-12-06 [1] RSPM (R 3.6.3)
 1 FNN             1.1.3.1  2022-05-23 [1] RSPM (R 3.6.3)
 1 fontawesome     0.5.0    2023-01-25 [1] RSPM (R 3.6.3)
 1 foreach         1.5.2    2022-02-02 [1] RSPM (R 3.6.3)
 1 forecast      * 8.20     2023-01-06 [1] RSPM (R 3.6.3)
 1 foreign         0.8-75   2020-01-20 [2] CRAN (R 3.6.3)
 1 fracdiff        1.5-2    2022-10-31 [1] RSPM (R 3.6.3)
 1 FrF2          * 2.2-3    2022-05-09 [1] RSPM (R 3.6.3)
 1 fs              1.6.0    2023-01-23 [1] RSPM (R 3.6.3)
 1 generics        0.1.3    2022-07-05 [1] RSPM (R 3.6.3)
 1 geometry      * 0.4.6.1  2022-07-04 [1] RSPM (R 3.6.3)
 1 GGally        * 2.1.2    2021-06-21 [1] RSPM (R 3.6.3)
 1 ggdendro      * 0.1.23   2022-02-16 [1] RSPM (R 3.6.3)
 1 ggforce       * 0.4.1    2022-10-04 [1] RSPM (R 3.6.3)
 1 ggplot2       * 3.4.0    2022-11-04 [1] RSPM (R 3.6.3)
 1 ggrepel       * 0.9.2    2022-11-06 [1] RSPM (R 3.6.3)
 1 glmnet        * 4.1-2    2021-06-24 [1] RSPM (R 3.6.3)
 1 glue            1.6.2    2022-02-24 [2] CRAN (R 3.6.3)
 1 gmp             0.6-10   2023-01-17 [1] RSPM (R 3.6.3)
 1 grf           * 2.2.1    2022-12-14 [1] RSPM (R 3.6.3)
 1 gridExtra       2.3      2017-09-09 [1] RSPM (R 3.6.3)
 1 gstat           2.0-7    2021-03-19 [1] RSPM (R 3.6.3)
 1 gtable          0.3.1    2022-09-01 [1] RSPM (R 3.6.3)
 1 gtools        * 3.9.4    2022-11-27 [1] RSPM (R 3.6.3)
 1 here            1.0.1    2020-12-13 [1] RSPM (R 3.6.3)
 1 hexbin        * 1.28.2   2021-01-08 [1] RSPM (R 3.6.3)
 1 hms             1.1.2    2022-08-19 [1] RSPM (R 3.6.3)
 1 htmltools       0.5.4    2022-12-07 [1] CRAN (R 3.6.3)
 1 htmlwidgets     1.6.1    2023-01-07 [1] RSPM (R 3.6.3)
 1 httpuv          1.6.8    2023-01-12 [1] RSPM (R 3.6.3)
 1 httr          * 1.4.4    2022-08-17 [1] RSPM (R 3.6.3)
 1 ICEbox        * 1.1.5    2022-08-22 [1] RSPM (R 3.6.3)
 1 igraph          1.3.5    2022-09-22 [1] RSPM (R 3.6.3)
 1 ingredients     2.3.0    2023-01-15 [1] RSPM (R 3.6.3)
 1 intervals       0.15.2   2020-04-04 [1] RSPM (R 3.6.3)
 1 iterators       1.0.14   2022-02-05 [1] RSPM (R 3.6.3)
 1 jose            1.2.0    2021-11-06 [1] RSPM (R 3.6.3)
 1 jquerylib       0.1.4    2021-04-26 [1] RSPM (R 3.6.3)
 1 jsonlite      * 1.8.4    2022-12-06 [1] RSPM (R 3.6.3)
 1 kableExtra    * 1.3.4    2021-02-20 [1] RSPM (R 3.6.3)
 1 keras         * 2.11.0   2022-12-20 [1] RSPM (R 3.6.3)
 1 knitr           1.42     2023-01-25 [1] RSPM (R 3.6.3)
 1 later           1.3.0    2021-08-18 [1] RSPM (R 3.6.3)
 1 lattice         0.20-38  2018-11-04 [2] CRAN (R 3.6.3)
 1 lazyeval        0.2.2    2019-03-15 [1] RSPM (R 3.6.3)
 1 lhs             1.1.6    2022-12-17 [1] RSPM (R 3.6.3)
 1 lifecycle       1.0.3    2022-10-07 [1] RSPM (R 3.6.3)
 1 lmtest          0.9-40   2022-03-21 [1] RSPM (R 3.6.3)
 1 lubridate     * 1.9.1    2023-01-24 [1] RSPM (R 3.6.3)
 1 magic           1.6-1    2022-11-16 [1] RSPM (R 3.6.3)
 1 magrittr        2.0.3    2022-03-30 [1] RSPM (R 3.6.3)
 1 maptools        1.1-6    2022-12-14 [1] RSPM (R 3.6.3)
 1 maptree         1.4-8    2022-04-06 [1] RSPM (R 3.6.3)
 1 MASS          * 7.3-58.2 2023-01-23 [1] RSPM (R 3.6.3)
 1 mathjaxr        1.6-0    2022-02-28 [1] RSPM (R 3.6.3)
 1 Matrix        * 1.5-3    2022-11-11 [1] RSPM (R 3.6.3)
 1 mco             1.15.6   2020-10-09 [1] RSPM (R 3.6.3)
 1 memoise       * 2.0.1    2021-11-26 [1] RSPM (R 3.6.3)
 1 mice          * 3.15.0   2022-11-19 [1] RSPM (R 3.6.3)
 1 mime            0.12     2021-09-28 [1] CRAN (R 3.6.3)
 1 minimalRSD    * 1.0.0    2017-01-04 [1] RSPM (R 3.6.2)
 1 miniUI          0.1.1.1  2018-05-18 [1] RSPM (R 3.6.3)
 1 misc3d          0.9-1    2021-10-07 [1] RSPM (R 3.6.3)
 1 mlr           * 2.19.1   2022-09-29 [1] RSPM (R 3.6.3)
 1 mlrMBO        * 1.1.5.1  2022-07-04 [1] RSPM (R 3.6.3)
 1 munsell         0.5.0    2018-06-12 [1] RSPM (R 3.6.3)
 1 nabor         * 0.5.0    2018-07-11 [1] RSPM (R 3.6.3)
 1 nlme            3.1-144  2020-02-06 [2] CRAN (R 3.6.3)
 1 nnet          * 7.3-18   2022-09-28 [1] RSPM (R 3.6.3)
 1 numbers         0.8-2    2021-05-14 [1] RSPM (R 3.6.3)
 1 onehot        * 0.1.1    2017-05-02 [1] RSPM (R 3.6.2)
 1 openssl         2.0.5    2022-12-06 [1] RSPM (R 3.6.3)
 1 openxlsx      * 4.2.5.1  2022-10-24 [1] RSPM (R 3.6.3)
 1 parallelMap   * 1.5.1    2021-06-28 [1] RSPM (R 3.6.3)
 1 ParamHelpers  * 1.14.1   2022-07-04 [1] RSPM (R 3.6.3)
 1 partitions      1.10-7   2022-07-21 [1] RSPM (R 3.6.3)
 1 pdp           * 0.8.1    2022-06-07 [1] RSPM (R 3.6.3)
 1 pillar          1.8.1    2022-08-19 [1] RSPM (R 3.6.3)
 1 pkgconfig       2.0.3    2019-09-22 [1] RSPM (R 3.6.3)
 1 plot3D          1.4      2021-05-22 [1] RSPM (R 3.6.3)
 1 plotly        * 4.10.1   2022-11-07 [1] RSPM (R 3.6.3)
 1 pls           * 2.8-1    2022-07-16 [1] RSPM (R 3.6.3)
 1 plumber       * 1.2.1    2022-09-06 [1] RSPM (R 3.6.3)
 1 plyr            1.8.8    2022-11-11 [1] RSPM (R 3.6.3)
 1 png             0.1-8    2022-11-29 [1] RSPM (R 3.6.3)
 1 polyclip        1.10-4   2022-10-20 [1] RSPM (R 3.6.3)
 1 polynom         1.4-1    2022-04-11 [1] RSPM (R 3.6.3)
 1 pROC          * 1.18.0   2021-09-03 [1] RSPM (R 3.6.3)
 1 promises        1.2.0.1  2021-02-11 [1] RSPM (R 3.6.3)
 1 proxy           0.4-27   2022-06-09 [1] RSPM (R 3.6.3)
 1 pso           * 1.0.4    2022-04-12 [1] RSPM (R 3.6.3)
 1 purrr           1.0.1    2023-01-10 [1] RSPM (R 3.6.3)
 1 quadprog        1.5-8    2019-11-20 [1] RSPM (R 3.6.3)
 1 quantmod        0.4.20   2022-04-29 [1] RSPM (R 3.6.3)
 1 R6              2.5.1    2021-08-19 [1] RSPM (R 3.6.3)
 1 ragg          * 1.2.5    2023-01-12 [1] RSPM (R 3.6.3)
 1 randomForest  * 4.6-14   2018-03-25 [1] RSPM (R 3.6.3)
 1 ranger        * 0.14.1   2022-06-18 [1] RSPM (R 3.6.3)
 1 rappdirs        0.3.3    2021-01-31 [2] CRAN (R 3.6.3)
 1 rbibutils       2.2.13   2023-01-13 [1] RSPM (R 3.6.3)
 1 rclipboard    * 0.1.6    2022-08-07 [1] RSPM (R 3.6.3)
 1 RColorBrewer  * 1.1-3    2022-04-03 [1] RSPM (R 3.6.3)
 1 Rcpp          * 1.0.10   2023-01-22 [1] RSPM (R 3.6.3)
 2 RcppParallel    5.1.6    2023-01-09 [1] RSPM (R 3.6.3)
 1 RcppZiggurat  * 0.1.6    2020-10-20 [1] RSPM (R 3.6.3)
 1 Rdpack          2.4      2022-07-20 [1] RSPM (R 3.6.3)
 1 readr         * 2.1.3    2022-10-01 [1] RSPM (R 3.6.3)
 1 readxl        * 1.4.1    2022-08-17 [1] RSPM (R 3.6.3)
 1 reshape         0.8.9    2022-04-12 [1] RSPM (R 3.6.3)
 1 reticulate    * 1.28     2023-01-27 [1] RSPM (R 3.6.3)
 1 Rfast         * 2.0.3    2021-05-17 [1] RSPM (R 3.6.3)
 1 RJSONIO         1.3-1.8  2023-01-31 [1] RSPM (R 3.6.3)
 1 rlang           1.0.6    2022-09-24 [1] RSPM (R 3.6.3)
 1 rmarkdown       2.20     2023-01-19 [1] RSPM (R 3.6.3)
 1 rpart         * 4.1.19   2022-10-21 [1] RSPM (R 3.6.3)
 1 rprojroot       2.0.3    2022-04-02 [2] CRAN (R 3.6.3)
 1 rsconnect       0.8.29   2023-01-09 [1] RSPM (R 3.6.3)
 1 rstudioapi      0.14     2022-08-22 [1] RSPM (R 3.6.3)
 1 Rtsne         * 0.16     2022-04-17 [1] RSPM (R 3.6.3)
 1 rvest           1.0.3    2022-08-19 [1] RSPM (R 3.6.3)
 1 sass            0.4.5    2023-01-24 [1] RSPM (R 3.6.3)
 1 scales          1.2.1    2022-08-20 [1] RSPM (R 3.6.3)
 1 scatterplot3d   0.3-42   2022-09-08 [1] RSPM (R 3.6.3)
 1 sensitivity   * 1.27.1   2022-08-09 [1] RSPM (R 3.6.3)
 1 sessioninfo   * 1.2.2    2021-12-06 [1] RSPM (R 3.6.3)
 1 sfsmisc       * 1.1-14   2022-11-24 [1] RSPM (R 3.6.3)
 1 shape           1.4.6    2021-05-19 [1] RSPM (R 3.6.3)
 1 shiny         * 1.7.4    2022-12-15 [1] RSPM (R 3.6.3)
 1 shinyFiles    * 0.9.3    2022-08-19 [1] RSPM (R 3.6.3)
 1 shinyjqui     * 0.4.1    2022-02-03 [1] RSPM (R 3.6.3)
 1 shinyWidgets  * 0.7.6    2023-01-08 [1] RSPM (R 3.6.3)
 1 SimJoint      * 0.3.9    2021-12-09 [1] RSPM (R 3.6.3)
 1 smoof         * 1.6.0.2  2020-02-18 [1] RSPM (R 3.6.3)
 1 sp            * 1.6-0    2023-01-19 [1] RSPM (R 3.6.3)
 1 spacetime       1.2-8    2022-06-17 [1] RSPM (R 3.6.3)
 1 stringi         1.7.12   2023-01-11 [1] RSPM (R 3.6.3)
 1 stringr       * 1.5.0    2022-12-02 [1] RSPM (R 3.6.3)
 1 survival        3.1-8    2019-12-03 [2] CRAN (R 3.6.3)
 1 svglite         2.1.1    2023-01-10 [1] RSPM (R 3.6.3)
 1 swagger         3.33.1   2020-10-02 [1] CRAN (R 3.6.3)
 1 systemfonts     1.0.4    2022-02-11 [1] RSPM (R 3.6.3)
 1 tensorflow    * 2.11.0   2022-12-19 [1] RSPM (R 3.6.3)
 1 textshaping     0.3.6    2021-10-13 [1] RSPM (R 3.6.3)
 1 tfruns          1.5.1    2022-09-05 [1] RSPM (R 3.6.3)
 1 tgp           * 2.4-17   2020-09-20 [1] RSPM (R 3.6.3)
 1 tibble          3.1.8    2022-07-22 [1] CRAN (R 3.6.3)
 1 tidyr           1.3.0    2023-01-24 [1] RSPM (R 3.6.3)
 1 tidyselect      1.2.0    2022-10-10 [1] RSPM (R 3.6.3)
 1 timechange      0.2.0    2023-01-11 [1] RSPM (R 3.6.3)
 1 timeDate        4022.108 2023-01-07 [1] RSPM (R 3.6.3)
 1 tippy         * 0.1.0    2021-01-11 [1] RSPM (R 3.6.3)
 1 tseries         0.10-53  2023-01-31 [1] RSPM (R 3.6.3)
 1 TTR             0.24.3   2021-12-12 [1] CRAN (R 3.6.3)
 1 tweenr          2.0.2    2022-09-06 [1] RSPM (R 3.6.3)
 1 tzdb            0.3.0    2022-03-28 [1] RSPM (R 3.6.3)
 1 urca            1.3-3    2022-08-29 [1] RSPM (R 3.6.3)
 1 utf8            1.2.3    2023-01-31 [1] CRAN (R 3.6.3)
 1 uuid          * 1.1-0    2022-04-19 [1] RSPM (R 3.6.3)
 1 vcd             1.4-10   2022-06-09 [1] RSPM (R 3.6.3)
 1 vctrs           0.5.2    2023-01-23 [1] RSPM (R 3.6.3)
 1 viridis       * 0.6.2    2021-10-13 [1] RSPM (R 3.6.3)
 1 viridisLite   * 0.4.1    2022-08-22 [1] RSPM (R 3.6.3)
 1 waiter        * 0.2.5    2022-01-03 [1] RSPM (R 3.6.3)
 1 webshot         0.5.4    2022-09-26 [1] RSPM (R 3.6.3)
 1 webutils        1.1      2020-04-28 [1] CRAN (R 3.6.3)
 1 whisker         0.4.1    2022-12-05 [1] RSPM (R 3.6.3)
 1 withr           2.5.0    2022-03-03 [2] CRAN (R 3.6.3)
 1 xfun            0.37     2023-01-31 [1] RSPM (R 3.6.3)
 1 xgboost       * 0.90.0.2 2019-08-01 [1] RSPM (R 3.6.3)
 1 XML           * 3.99-0.3 2020-01-20 [1] RSPM (R 3.6.3)
 1 xml2            1.3.3    2021-11-30 [1] RSPM (R 3.6.3)
 1 xtable          1.8-4    2019-04-21 [1] RSPM (R 3.6.3)
 1 xts             0.12.2   2022-10-16 [1] RSPM (R 3.6.3)
 1 yaml            2.3.7    2023-01-23 [2] CRAN (R 3.6.3)
 1 zeallot         0.1.0    2018-01-28 [1] RSPM (R 3.6.3)
 1 zip             2.2.2    2022-10-26 [1] RSPM (R 3.6.3)
 1 zoo             1.8-11   2022-09-17 [1] RSPM (R 3.6.3)

 [1] C:/Apps/.checkpoint/2023-02-01/lib/x86_64-w64-mingw32/3.6.3
 [2] C:/Apps/R-3.6.3/library

 D -- DLL MD5 mismatch, broken installation.

- Python configuration ---------------------------------------------------------------------------------------------------------------------------------
 python:         C:/Apps/Anaconda/envs/rpy/python.exe
 libpython:      C:/Apps/Anaconda/envs/rpy/python38.dll
 pythonhome:     C:/Apps/Anaconda/envs/rpy
 version:        3.8.6 | packaged by conda-forge | (default, Jan 25 2021, 22:54:47) [MSC v.1916 64 bit (AMD64)]
 Architecture:   64bit
 numpy:          C:/Apps/Anaconda/envs/rpy/Lib/site-packages/numpy
 numpy_version:  1.21.6
 tensorflow:     C:\Apps\Anaconda\envs\rpy\lib\site-packages\tensorflow\__init__.p
 
 NOTE: Python version was forced by use_python function

Example application or steps to reproduce the problem

Plumber Code

function(req) {
    tempFolder <- 'temp/'
    
    uuid <- UUIDgenerate()
    remotePath <- paste0(tempFolder, uuid)
    
    # upload data file
    tmpFile <- tempfile()

    #! this step won't work when calling from C# as req$body$file does not exist
    writeBin(req$body$file$parsed, tmpFile)
    
    return(uuid)
}

Describe the problem in detail

C# client-side code
This does not work

// Create an HttpClient instance
using var httpClient = new HttpClient(new ClientHandler());

// Create a multipart form data content
// Setting the content type manually does not work, I've tried that
var content = new MultipartFormDataContent();

// Read the file content as a byte array -> dataPath is defined further up and points to an excel file
var fileContent = File.ReadAllBytes(dataPath);

// Add the file content as a ByteArrayContent to the multipart form data
content.Add(new ByteArrayContent(fileContent), "file.xlsx", "file.xlsx");

// Make the POST request
var response = await httpClient.PostAsync(new Uri($"{autosumApi}/send"), content);

// Read and print the response
var responseText = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseText.First());

The response I get is 500 /w ["Error in writeBin(req$body$file$parsed, tmpFile): can only write vector objects\n"]

C# client-side request

Request:
Method: POST, RequestUri: 'http://127.0.0.1:6285/', Version: 1.1, Content: System.Net.Http.MultipartFormDataContent, Headers:
{
  Content-Type: multipart/form-data
}

Python client-side code
This works

import requests
response = requests.post(
    url = plumberAPIUrl + 'send',
    files = {'file': open(filePath, 'rb')})

If I return the request, I get a UUID back, as expected.

Python client-side request

b'POST /send HTTP/1.1\r
Host: 127.0.0.1:6285\r
User-Agent: python-requests/2.22.0\r
Accept-Encoding: gzip, deflate\r
Accept: */*\r\nConnection: keep-alive\r
Content-Length: 21020\r
Content-Type: multipart/form-data; boundary=3047d955cd6dabff7ef7a80b86abbb45'
@slodge
Copy link

slodge commented Sep 11, 2023

I think (but haven't tested) that you need to change your C# code to

content.Add(new ByteArrayContent(fileContent), "file", "file.xlsx");

See https://learn.microsoft.com/en-us/dotnet/api/system.net.http.multipartformdatacontent.add?view=net-7.0#system-net-http-multipartformdatacontent-add(system-net-http-httpcontent-system-string-system-string) - the second parameter is the name of the form variable

PS Sorry for slow response... I'm hoping Posit can put some <3 into Plumber again one day soon... // cc @schloerke @jcheng5

@slodge
Copy link

slodge commented Nov 10, 2023

I've been trying to get the same situation working today...

And ended up digging inside plumber and webutils as I couldn't get it to work.

Eventually I worked out that there's a problem with plumber's multipart parsing if the boundary marker is quoted - i.e. if it's presented in the content type headers like: multipart/form-data; boundary="custom_boundary_123" rather than multipart/form-data; boundary=custom_boundary_123

I've fixed this in my plumber fork - slodge@f0e37b8 - which is in #905 - but I don't have any timeline on if/when that might get merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants