Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

374
Views
Send a vector using the R httr GET function's `query` parameter

For sending a vector of values, say an array list_a = c(1,2,3) FastAPI will accept a URL of the form:

https://wherever.com/endpoint?list_a=1&list_a=2&list_a=3

However using library httr's query parameter to the GET function, you have to pass a list of key/value pairs. This means you can't have the same field twice because R will not accept a list with duplicate keys obviously.

So how do I do this? I could build the URL myself, but the problem with that is some of my parameters have double quotes (") in them which don't seem to be parsed properly if I put them directly into the url. The query parameter does seem to handle these properly however.

Is there any way to get the query parameter of httr's GET to create multiple identical field names?

Alternatively how do I encode a pre-created URL that has double quotes in it like the one below so that it does not cause FastAPI to give at HTTP error?

"query/Crude/?actual_table_name=live.crude&report_id=xxxxxxx&fields=IMO&where={\"Barrels\":{\"gt\":1},\"conjunction\":\"\"}&where={\"Load Date\":{\"gt\":\"'2000-01-01'\"},\"conjunction\":\"\"}&offset=1e+05&limit=10000"

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I think it would be easiest to build the query string yourself, then you could use URLencode on the result:

url <- "query/Crude/?actual_table_name=live.crude&report_id=xxxxxxx&fields=IMO&where={\"Barrels\":{\"gt\":1},\"conjunction\":\"\"}&where={\"Load Date\":{\"gt\":\"'2000-01-01'\"},\"conjunction\":\"\"}&offset=1e+05&limit=10000"
URLencode(url)
#> [1] "query/Crude/?actual_table_name=live.crude&report_id=xxxxxxx&fields=IMO&where=%7B%22Barrels%22:%7B%22gt%22:1%7D,%22conjunction%22:%22%22%7D&where=%7B%22Load%20Date%22:%7B%22gt%22:%22'2000-01-01'%22%7D,%22conjunction%22:%22%22%7D&offset=1e+05&limit=10000"
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!