方法1 curl
パラメタのstringは''で囲まなくてok
パラメタを配列として渡したい場合:
例えばids: [1, 2, 3]をパラメタとして渡したい時
curl http://localhost:3000/internal/v1/users/partner_organizations?いids[]=1&ids[]=2&ids[]=3
一つずつ渡さないといけない...
curl: (3) [globbing] bad range specification in column 136
とか出る時
curl --globoff http://localhost:3000/internal/v1/users/partner_organizations\?user_ids\[\]\=1
--globoffとすれば良い
globoffドキュメント
-g/--globoff
This option switches off the "URL globbing parser". When you set this option, you can
specify URLs that contain the letters {}[] without having them being interpreted by curl
itself. Note that these letters are not normal legal URL contents but they should be
encoded according to the URI standard.
方法2 rails cでconsoleを起動しrailsのapiを叩くgem HTTPartyを使う
(アプリケーションでHTTParty gemを使っていることを前提とする)
rails cでconsoleを起動、以下で行ける。
パラメタの渡し方がラク。
url = 'http://localhost:3000/internal/v1/users/partner_organizations'
params = {application_token: 'honya', user_id: [24, 13, 14]}
method = :get
a = JSON.parse(HTTParty.send(method, url, { body: params }).body)
cf) JSON.parseってやるとjson(配列形式)にしてくれる