Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

385
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda