# HTTP POSTs

**URL:** <https://www.ruby-forum.com/t/http-posts/119299>\
**Category:** Rails\
**Created:** [November 5, 2007, 10:14pm UTC](https://www.ruby-forum.com/t/http-posts/119299 "2007-11-05T22:14:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![doug3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b3f665/32.png) [@doug3](https://www.ruby-forum.com/u/doug3)\
**Post date:** [November 5, 2007, 10:14pm UTC](https://www.ruby-forum.com/t/http-posts/119299/1 "2007-11-05T22:14:19Z")

</div>

Hi all, this may sound basic, but I’m not able to figure out how to  
initiate an http post action from within a controller.

What I’m trying to do is use a def function in one of my application  
controllers to send a post on to another URI (using the http POST  
method) that is not on my server.

I tried post(path, parameters=nil, headers=nil) but only got an error  
message saying post method not found.

I also tried a redirect, but it seems this method only wants to initiate  
http GET actions.

Any ideas or examples?

Thanks,

Doug

---

<div class="post-metadata">

**Author:** ![doug3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b3f665/32.png) [@doug3](https://www.ruby-forum.com/u/doug3)\
**Post date:** [November 5, 2007, 10:27pm UTC](https://www.ruby-forum.com/t/http-posts/119299/2 "2007-11-05T22:27:03Z")

</div>

> What I’m trying to do is use a def function in one of my  
> application controllers to send a post on to another URI  
> (using the http POST  
> method) that is not on my server.

You’re going to want to look at the net/http and/or mechanize libraries  
for that.

> I also tried a redirect, but it seems this method only wants  
> to initiate http GET actions.

Do you mean you want your response to the originating client to cause it  
to issue a POST request to an arbitrary URL? You can’t do that. You can  
have the rails app issue a POST request, but you can’t force the  
originating client to do so.

- donald

---

<div class="post-metadata">

**Author:** ![doug3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b3f665/32.png) [@doug3](https://www.ruby-forum.com/u/doug3)\
**Post date:** [November 6, 2007, 9:35pm UTC](https://www.ruby-forum.com/t/http-posts/119299/3 "2007-11-06T21:35:56Z")

</div>

Ball, Donald A Jr (Library) wrote:

> > What I’m trying to do is use a def function in one of my  
> > application controllers to send a post on to another URI  
> > (using the http POST  
> > method) that is not on my server.
> 
> You’re going to want to look at the net/http and/or mechanize libraries  
> for that.
> 
> > I also tried a redirect, but it seems this method only wants  
> > to initiate http GET actions.
> 
> Do you mean you want your response to the originating client to cause it  
> to issue a POST request to an arbitrary URL? You can’t do that. You can  
> have the rails app issue a POST request, but you can’t force the  
> originating client to do so.
> 
> - donald

Thanks Don. No, I don’t want my response to the originating client to  
cause it to issue a POST request to an arbitrary URL? All I want to do  
is generate an HTTP POST (to another URL from within the controller –  
as opposed to presenting a form to a user and waiting for the user click  
a submit button. For example, my application has a form that when  
submitted posts data to a third party shopping cart application. When  
users are in that application, they can hit a “continue shopping” button  
which generates a GET request to my application. Instead of actually  
showing the user a catalog, I simply want to catch the GET request and  
automatically generate a POST back to the third party shopping cart  
application.

I’ll do as you suggest and take a look at net/http library.

Thanks again,

Doug
