Skip to content Skip to sidebar Skip to footer

Is There A Way In Ant (using Groovy?) To Post Info To An Http URL And Then Parse The Response?

I've found a way to read an HTML page in Ant with Groovy + HTMLCleaner (see: Parse HTML using with an Ant Script ) but I am unable to find a way to first POST some data to a URL an

Solution 1:

You can use the groovy REST client, which is part of the HTTPBuilder project.

<target name="invoke-webservice">
    <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>

    <groovy>
        import groovyx.net.http.RESTClient
        import groovy.util.slurpersupport.GPathResult
        import static groovyx.net.http.ContentType.URLENC

        def twitter = new RESTClient( 'https://twitter.com/statuses/' )

        def resp = twitter.post( path : 'update.xml',
                 body : [ status:msg, source:'httpbuilder' ],
                 requestContentType : URLENC )

        log.info "response status: ${resp.status}"
    </groovy>
</target>

Post a Comment for "Is There A Way In Ant (using Groovy?) To Post Info To An Http URL And Then Parse The Response?"