Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

testing rails grape API with curl, params array

I am manually testing my rails application grape API using curl. I would like to send a [1,2,3] array as a request query parameter for to to be accesible like:

p params[:tickets_ids]
=> [1,2,3]

I only found clues how to send something what is interpreted as hash .

I will be grateful for a clue how to post an array using curl.

like image 764
pawurb Avatar asked Dec 12 '25 17:12

pawurb


1 Answers

Thank you for the clue. The answer is to encode query like this:

?&tickets_ids[]=1&tickets_ids[]=2&tickets_ids[]=3

Results in:

p params[:tickets_ids]
=> ["1", "2", "3"]
like image 125
pawurb Avatar answered Dec 15 '25 13:12

pawurb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!