import groovy.json.JsonOutput
void api(){ def data = [jobId : "11111111111111", data : 5,status: 2] def url = new URL("") def conn = url.openConnection() conn.setRequestMethod("POST") conn.setRequestProperty("Content-Type", "application/json") conn.doOutput = true def writer = new OutputStreamWriter(conn.outputStream) println JsonOutput.toJson(data) writer.write(JsonOutput.toJson(data)) writer.flush() writer.close() conn.connect() def code = conn.getResponseCode() println conn.content.text println code }