Forum Discussion

keithmcooper's avatar
keithmcooper
New Contributor
3 years ago

My plumber api (swagger) no longer accepts '&' to separate multiple parameter input values.

My R plumber api works fine when using a single value for a query parameter (e.g. 'in_subject' = A). However, when I add an additional value, separated by '&' , I get nothing (see fig). I'm pretty sure adding '&' between items in a list previously worked. Any help greatly appreciated!

Repro using R:

 

library(plumber)

library(dplyr)

subject <- c("A", "B", "C", "D", "E")

age <- c(23, 41, 32, 58, 26)

df <- data.frame(subject, age)

 

#* @apiTitle repro

#* Returns Data in JSON format

#* Param in_subject

#* @get /S

function(in_subject) {

df %>% filter( subject == in_subject)

}

 

  • Problem solved thanks to @meztez. Just needed to add define the parameter as an array by encoding the type within square brackets:

     

    library(plumber)

    library(dplyr)

    subject <- c("A", "B", "C", "D", "E")

    age <- c(23, 41, 32, 58, 26)

    df <- data.frame(subject, age)

    #* @apiTitle repro

    #* Returns Data in JSON format

    #* Param in_subject:[string]

    #* @get /S

    function(in_subject) {

    df %>% filter( subject == in_subject )

    }

     

  • Problem solved thanks to @meztez. Just needed to add define the parameter as an array by encoding the type within square brackets:

     

    library(plumber)

    library(dplyr)

    subject <- c("A", "B", "C", "D", "E")

    age <- c(23, 41, 32, 58, 26)

    df <- data.frame(subject, age)

    #* @apiTitle repro

    #* Returns Data in JSON format

    #* Param in_subject:[string]

    #* @get /S

    function(in_subject) {

    df %>% filter( subject == in_subject )

    }