# Passing Query String while doing http authentication

**URL:** <https://www.ruby-forum.com/t/passing-query-string-while-doing-http-authentication/90265>\
**Category:** Rails\
**Created:** [March 27, 2007, 6:39am UTC](https://www.ruby-forum.com/t/passing-query-string-while-doing-http-authentication/90265 "2007-03-27T06:39:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/13edae/32.png) [@kiran](https://www.ruby-forum.com/u/kiran)\
**Post date:** [March 27, 2007, 6:39am UTC](https://www.ruby-forum.com/t/passing-query-string-while-doing-http-authentication/90265/1 "2007-03-27T06:39:05Z")

</div>

Hi,

```
I am trying to read content of url after doing http authentication.

```

using  
the below code query string(UserID=1) is not passed properly in the  
request.  
I am new to ruby so please let me know what are the changes that  
have to  
be done

```
test_username='testuser1'
test_password='password'
url = URI.parse('http://www.someurl456.com/apps/GetName?UserID=1')

req = Net::HTTP::Get.new(url.path)
req.basic_auth test_username, test_password
res = Net::HTTP.new(url.host, url.port).start {|http|

```

http.request(req) }  
response=res.body

```
 If http authentication is not required i can try:
response=open("http://www.someurl456.com/apps/GetName?UserID=1'").read

```

Thanks  
Kiran

---

<div class="post-metadata">

**Author:** ![kiran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/13edae/32.png) [@kiran](https://www.ruby-forum.com/u/kiran)\
**Post date:** [March 27, 2007, 8:46am UTC](https://www.ruby-forum.com/t/passing-query-string-while-doing-http-authentication/90265/2 "2007-03-27T08:46:54Z")

</div>

any solutions for this please?

---

<div class="post-metadata">

**Author:** ![kiran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/13edae/32.png) [@kiran](https://www.ruby-forum.com/u/kiran)\
**Post date:** [November 28, 2007, 1:15pm UTC](https://www.ruby-forum.com/t/passing-query-string-while-doing-http-authentication/90265/3 "2007-11-28T13:15:34Z")

</div>

Kiran wrote:

> any solutions for this please?

This works for me.

`http.start do |http|
  request = Net::HTTP::Get.new(instruction)
  request.basic_auth USERNAME, PASSWORD
  response = http.request(request)
end`
