Created
October 20, 2015 22:56
-
-
Save noel-yap/e16a6b484d62100cb408 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def doHttpPost(final String path, final String query) { | |
| final authority = 'example.com' | |
| final url = new URL("http://${authority}/${path}") | |
| final connection = url.openConnection() | |
| connection.with { | |
| setRequestMethod('POST') | |
| doOutput = true | |
| final writer = new OutputStreamWriter(outputStream) | |
| writer.with { | |
| write(query) | |
| flush() | |
| close() | |
| } | |
| connect() | |
| new JsonSlurper().parseText(content.text) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment