Help understanding problem rendering PDF with Plumber

I'm having problems understanding what I'm doing wrong when serializing a report using plumber

#* produce the report
#* @param userID:str userID
#* @param title:str title of repot
#* @param taskId:str id of the task
#* @param alpha:double confidence interval for plots
#* @serializer contentType list(type = "application/pdf")
#* @get /pdf

function(userID = "realUser1", 
         title = "Draft Report task1",
         taskId = "realRask1",
         alpha = 0.1){
  tmp <- tempfile()
  name = paste0(tmp,'.pdf')
  res$setHeader("Content-Disposition", paste0("attachment; filename=", basename(name)))
  rmarkdown::render(input = "~/BiologyAPP/BiologyAPI/BiologicalDataAPI/reports/testReport.Rmd", 
                    output_file= tmp,
                    params = list(author= userID,
                                  title= title,
                                  date= Sys.Date(),
                                  taskId= taskId,
                                  alpha= alpha))
  on.exit({file.remove(name)}, add = TRUE)
  readBin(name, "raw", n=file.info(name)$size)
}

for some reason I can't run the code if I use the tag serializer. it returns:

"Running plumber API at http://127.0.0.1:9064
Error in nchar(ctype) :
cannot coerce type 'closure' to vector of type 'character'"

but the same error disappears if I remove the tag, of course that then I've problems on the other end for deserializing an unknown file

What's the output of your sessionInfo()?

sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS: /usr/local/R/lib64/R/lib/libRblas.so
LAPACK: /usr/local/R/lib64/R/lib/libRlapack.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.