# How do make it post instead of get?

**URL:** <https://www.ruby-forum.com/t/how-do-make-it-post-instead-of-get/142594>\
**Category:** Ruby\
**Created:** [July 9, 2008, 3:37pm UTC](https://www.ruby-forum.com/t/how-do-make-it-post-instead-of-get/142594 "2008-07-09T15:37:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![weasel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a3d4f5/32.png) [@weasel](https://www.ruby-forum.com/u/weasel)\
**Post date:** [July 9, 2008, 3:37pm UTC](https://www.ruby-forum.com/t/how-do-make-it-post-instead-of-get/142594/1 "2008-07-09T15:37:47Z")

</div>

This script will GET the page i request when i call it from dos-prompt  
like this “ruby nukeuser.rb 1”

* * *

require ‘uri’  
require ‘net/https’

user\_id = ARGV[0].strip  
url = “https:///services\_captiveportal\_users.php?act=del&id=” + user\_id

url1 = URI.parse(url)

http = Net::HTTP.new(url1.host, url1.port)  
http.use\_ssl = true

# Do not warn us about certificate - blithely accept whatever

certificate we receive!  
http.verify\_mode = OpenSSL::SSL::VERIFY\_NONE

req = Net::HTTP::Get.new(url1.path)  
req.basic\_auth ‘username’, ‘password’

res = http.start do |h|  
h.request(req)  
end

print res.body

* * *

But i really need to POST… and cant figure out how to make it do that  
:-/  
Can someone please help - i am loosing my hair fast at the moment!

---

<div class="post-metadata">

**Author:** ![weasel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a3d4f5/32.png) [@weasel](https://www.ruby-forum.com/u/weasel)\
**Post date:** [July 9, 2008, 5:27pm UTC](https://www.ruby-forum.com/t/how-do-make-it-post-instead-of-get/142594/2 "2008-07-09T17:27:17Z")

</div>

Change

req = Net::HTTP::Get.new(url1.path)

to

req = Net::HTTP::Post.new(url1.path)

?

On Wed, Jul 9, 2008 at 2:33 PM, Flemming Munk jensen \<  
removed\_email\_address@domain.invalid\> wrote:

> ## Can someone please help - i am loosing my hair fast at the moment!
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

–  
Paul S.  
DCI Level 2 Judge, Bath FNM Organiser

Upcoming events in Bath - [nomadicfun.co.uk](http://nomadicfun.co.uk)  
July 12th Eventide Prerelease (Standard)

removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![weasel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a3d4f5/32.png) [@weasel](https://www.ruby-forum.com/u/weasel)\
**Post date:** [July 10, 2008, 8:26am UTC](https://www.ruby-forum.com/t/how-do-make-it-post-instead-of-get/142594/3 "2008-07-10T08:26:39Z")

</div>

Paul S. wrote:

> Change
> 
> req = Net::HTTP::Get.new(url1.path)
> 
> to
> 
> req = Net::HTTP::Post.new(url1.path)
> 
> ?

Well… that run’s without any errors too, but i dont get the result i  
would like.

I think i will explain a little more about what i am trying to do 😉

I have a webpage on a m0n0wall (see [m0n0wall](http://m0n0.ch/wall/)) where you can  
do some user management. On this page is a link that is marked up like  
this:

![]( "delete user")

Now what i want ruby to do is call the page  
services\_captiveportal\_users.php with the action “act=del” and the  
apropriate “id=?”, so i can delete users this way.

What happens so far, is i get the page with a list of all users  
currently registered, wich is ok, but the user id i request to be  
deleted is not deleted??

Is it maybe because of the "onclick=“return…blah” in the href??  
I have the feeling i am missing some basic law of nature here, and in  
the process of embarassing myself bigtime…

Thanks in advantage

BR  
Flemming
