Perhaps this curl script will be useful to you; unless you are trying to create a Groovy app that runs on the hub itself.