How to request by passing an array to the query with HTTP Client of Ruby

https://httpbin.org/get?params[]=a&params[]=b&params[]=c

If you want to request with such a URL, do as follows

sample.rb


#!/usr/bin/env ruby

require 'httpclient'

url = 'https://httpbin.org/get'
query = {
    'params[]' => ['a', 'b', 'c']
}
puts HTTPClient.get(url, query).body

test


$ ./sample.rb | jq '.args'
{
  "params[]": [
    "a",
    "b",
    "c"
  ]
}

Recommended Posts

How to request by passing an array to the query with HTTP Client of Ruby
The story of toString () starting with passing an array to System.out.println
How to convert an array of Strings to an array of objects with the Stream API
How to retrieve the hash value in an array in Ruby
[Swift5] How to get an array and the complement of arrays
How to find the cause of the Ruby error
[Swift] How to get the number of elements in an array (super basic)
[Note] [Beginner] How to write when changing the value of an array element in a Ruby iterative statement
[Ruby] How to find the sum of each digit
[Java] How to get a request by HTTP communication
How to output standard from an array with forEach
How to query Array in jsonb with Rails + postgres
How to boot by environment with Spring Boot of Maven
I tried to check the operation of http request (Put) with Talented API Tester
How to use git with the power of jgit in an environment without git commands
[ruby] How to assign a value to a hash by referring to the value and key of another hash
How to divide a two-dimensional array into four with ruby
Learning Ruby with AtCoder 13 How to make a two-dimensional array
[Ruby] How to retrieve the contents of a double hash
How to add elements without specifying the length of the array
[Rails] How to display the list of posts by category
How to deal with different versions of rbenv and Ruby
[Ruby] How to batch convert strings in an array to numbers
How to specify an array in the return value / argument of the method in the CORBA IDL file
[Rails] How to convert the URI of the image sent by http to https when using Twitter API
Try to imitate the idea of a two-dimensional array with a one-dimensional array
[Ruby] How to count even or odd numbers in an array
How to make an application with ruby on rails (assuming that the environment has been built)
How to output the value when there is an array in the array
[Java] How to search for a value in an array (or list) with the contains method
How to get the length of an audio file in java
How to decorate the radio button of rails6 form_with (helper) with CSS
[Spring Boot] I investigated how to implement post-processing of the received request.
How to read Body of Request multiple times with Spring Boot + Spring Security
[Swift] Summary of how to remove elements from an array (personal note)
[Java] How to turn a two-dimensional array with an extended for statement
How to access Socket directly with the TCP function of Spring Integration
Get the type of an array element to determine if it is an array
How to build an environment for any version of Ruby using rbenv
How to solve the local environment construction of Ruby on Rails (MAC)!
[Ruby On Rails] How to search the contents of params using include?
How to make the schema of the URL generated by Rails URL helper https
[swift5] How to change the color of TabBar or the color of item of TabBar with code
How to insert processing with any number of elements in iterative processing in Ruby
Compare the elements of an array (Java)
How to determine the number of parallels
Convert an array of strings to numbers
How to sort the List of SelectItem
Sort an array of Ruby homebrew classes
[Ruby] I want to make an array from a character string with the split method. And vice versa.
How to get the query string to actually issue when using PreparedStatement with JDBC
[Ruby on Rails] How to make the link destination part of the specified id
Use hashes well in Ruby to calculate the total amount of an order
graphql-ruby: How to get the name of query or mutation in controller Note
[Ruby] Learn how to use odd? Even? And count the even and odd numbers in the array!
If the parameter is an array, how to include it in Stopara's params.permit
How to get the ID of a user authenticated with Firebase in Swift
[Rails6] How to connect the posting function generated by Scaffold with the user function generated by devise
How to display the amount of disk used by Docker container for each container
[swift5] How to transition from the app to an external site by specifying the URL
[Ruby on Rails] Rails tutorial Chapter 14 Summary of how to implement the status feed