Ask a Question

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

SOLVED
keithmcooper
New Contributor

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!

keithmcooper_0-1663139849282.png

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)

}

 

1 REPLY 1
keithmcooper
New Contributor

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 )

}

 

cancel
Showing results for 
Search instead for 
Did you mean: