The code snippet below should do the job for you
def post = new URL("url_goes_here").openConnection();
def message = '{"message":"this is the data we want to post"}'
post.setRequestMethod("POST")
post.setDoOutput(true)
post.setRequestProperty("Content-Type", "application/json")
// add more headers if needed
post.getOutputStream().write(message.getBytes("UTF-8"));
def postRC = post.getResponseCode();
println(postRC);
if(postRC.equals(200)) {
println(post.getInputStream().getText());
}
CLICK HERE to find out more related problems solutions.