0

I need to open an external link, and send some params through post method. I have read that I can use redirect() to open a link through get method, as the following code:

    def get = {
        redirect(url: "http://localhost:8080/test/public/cadastro/dataConfirm.html?" + "username=" + "test")
    }

Apparently, redirect only works with get. Is there any command to do this by post method? Thanks.

raonirenosto
  • 1,507
  • 5
  • 19
  • 30

2 Answers2

2

Is your goal to have the user actually redirected to a different site via POST, or POST to a different site and get results back but stay in your site? If it is actually pushing the user to a different site then Victor's comment is the way to go.

If you are trying to send a POST to a different site, get results and stay on your site look into the Rest plugin and check out the withHttp method. There is a good example here.

There can be dependency issues when using the Rest plugin. If you have these check out the answer by ataylor in this stackoverflow post.

Community
  • 1
  • 1
Kelly
  • 3,709
  • 4
  • 20
  • 31
  • Thanks for your answer @Kelly. The second one is what I need. Server-to-server comunication. I'm not a big fan of grails plugins, so I found the java way to do this, but this is a good alternative too. I will answer my own question to let people know the other way. – raonirenosto Aug 09 '12 at 23:39
0

Server-to-server comunication via post in grails can be achieved using the following java code . I tested it and works fine in grails. The alternatives are plugins, as @Kelly answered me, and Apache Http Components .

raonirenosto
  • 1,507
  • 5
  • 19
  • 30