How to specify httr::GET array query

400 views Asked by At

I am trying to compose an httr::GET query where I must use a bracketed (array) query where the url resembles:

 #target = "http://example.com?abc[]=123"

This strategy does not seem to work:

 baseurl = "http://example.com"
 qy = list(abc="123")
 httr::GET(baseurl,query=qy)

R complains about invalid characters if I try:

qy = list(abc[]="123")

See also: Is array syntax using square brackets in URL query strings valid?

Array in body for httr POST request

1

There are 1 answers

0
Nick Kennedy On BEST ANSWER

You should be able to use

GET(url, query = list("abc[]" = 133))