def request = new URL("<YOUR ENDPOINT URL>").openConnection();
def message = '{
\"options\": {
\"method\": \"POST\",
\"headers\": {
\"Content-Type\": \"application/json\",
\"Accept\": \"application/json\"
},
\"body\": {
\"fields\": {
\"project\":{
\"name\": \"<your project name>\"
},
\"summary\": \"Create Issue via POST.\",
\"description\": \"Creating of an issue via a POST request using the API Key Manager\",
\"issuetype\": {
\"id\": \"<your issue type id>\"
}
}
}
},
\"url\": \"/rest/api/2/issue\"
}'
request.setRequestMethod("POST")
request.setDoOutput(true)
request.setRequestProperty("Content-Type", "application/json")
request.setRequestProperty("apiKey","<YOURTOKEN>")
request.getOutputStream().write(message.getBytes("UTF-8"));
def responseCode = request.getResponseCode();
println(responseCode);
if (responseCode.equals(200)) {
println(request.getInputStream().getText());
}