2

I am trying to use ellipsis with plumber as input json may vary

 #' @post /predict
    calculate_prediction <- function(...){
      arguments =list(...)
      print(arguments)
      return(arguments)

This throws me error below :

 <simpleError: No method asJSON S3 class: R6>

How to resolve this issue

1 Answers1

0

The issue with using ... in your function is that the first two arguments are the request body and the response body that are passed in the API call. If you add those in first, you can capture all the remaining unnamed args.

#' @post /predict

calculate_prediction <- function(req, res, ...){
      arguments = list(...)
      print(arguments)
      return(arguments)
}
Brian
  • 7,900
  • 1
  • 27
  • 41
  • Doesn't work in 0.4.6: – Maxim.K Aug 01 '19 at 15:30
  • @Maxim.K, what are you passing into your POST request? It needs to be arguments that can be converted to JSON, like vectors and lists. Is one of your variables the same name as a function maybe? – Brian Aug 02 '19 at 00:55