Server-to-server POST request

17 / Jan / 2011 by Aman Aggarwal 1 comments

Server to server POST request can be made using Apache Commons HttpClient library.
You need to include http-client jar file in project/lib folder and execute following lines of code:

HttpClient client = new HttpClient()
String url = "http://localhost:8080/test/person/delete/1"
PostMethod method = new PostMethod(url)
int returnCode = client.executeMethod(method) //Response Code: 200, 302, 304 etc.
def response = method.getResponseBodyAsString() // Actual response

Hope it helps


comments (1 “Server-to-server POST request”)

  1. Rohit


    My old application is Grails 1.1.1 based in which I have used Acegi security 0.5.2 and now I am developing Spring roo 1.1.3 application in which I am using spring security.
    Both application shares some links in between.
    Both have different login page, and useing LDAP authentication.
    Login credentials are same for both the application but Database is different.

    Now, I am calling j_spring_security_check url from Spring roo and successfully log in the Grails application, But
    When I call j_spring_security_check from Grails its not working because of “POST” method supported by j_spring_security_check.

    Is it possible to implement this using http client.

    Thanks & Regards,


Leave a Reply

Your email address will not be published. Required fields are marked *