Rails GET params

Victor Ivanov

TIL that one can send params in the body of request even if it is a GET request.

I was looking at the logs of a Rails app I was working with as a contractor and I saw something that caught my attention:

I, Started GET “/api/apps/8” for xx.xx.xxx.245 at 2017–06–12 05:41:07 +0x00
I, Processing by Api::V1::AppsController#show as JSON
I, Parameters: {“api_token”=>”xxxxxxxxxx”, “language_code”=>”EN”, “id”=>”8"}

So, there were no `api_token` or `language_code` in the URL, but they were avail for the controller. At first I thought they were passed via headers (that’s what you usually do to pass auth token in a mobile app), but I couldn’t find any code in Rack middleware that was parsing headers for that params.

So, I asked some people and finally one fellow freelancer suggested that those parameters were part of the request body. You can’t do that in the browser, it is against the spec, but possible to do with `curl` or custom HTTP client (in this case it was BestHTTP)

Here is a SO link: https://stackoverflow.com/questions/978061/http-get-with-request-body

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade