malcoauri
malcoauri

Reputation: 12199

GET request in Rails with big count of params

I want to make some Rails API for a mobile app, and there is the following situation: my app will authorize using a phone number (like Viber / WhatsApp); also it can automatically detect which contacts from a phone book also have my app installed. If I understand right I should create some GET method to take array of numbers and return numbers of users which have been in my system already. There are no problem with GET method for me and arrays in GET params, but phone book of users can be very big, and sending all numbers in GET params is not good solution. How can I do it right? Should I divide numbers in parts and send first 10 numbers, then next 10 numbers etc? Thanks in advance.

Upvotes: 1

Views: 183

Answers (2)

Greg Burghardt
Greg Burghardt

Reputation: 18868

You could also optimize your query string:

?ph=5551112222,5552223333...

This at least minimizes the request size. I think Rails should give you params[:ph] as an array. If not then splitting the string on a comma is just one extra line of code.

Upvotes: 0

Maurício Linhares
Maurício Linhares

Reputation: 40333

Just use a POST request instead. You don't have to always use GET when you're searching for stuff.

Upvotes: 1

Related Questions