My idea is create issues via rest api with scriptrunner. It seems to be Error 400 (Bad Request). I tried the data json variable in Postman and works, so i guess there is an error in the HEAD. Can someone help me?
import groovy.json.StreamingJsonBuilder
def authString = "user:passw".getBytes().encodeBase64().toString()
def body_req = [
"fields": [
"project" : [ "key" : "TR" ],
"summary" : "test",
"description" : "test",
"issuetype" : [ "name" : "Incident" ]]
]
def baseURL = "<<JIRA_LINK>>/rest/api/2/issue/"
URL url
url = new URL(baseURL)
HttpURLConnection connection = (HttpURLConnection)url.openConnection()
connection.setRequestMethod( "POST" )
connection.setRequestProperty( "Authorization", "Basic ${authString}" )
connection.doOutput = true
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8")
connection.outputStream.withWriter("UTF-8") { new StreamingJsonBuilder(it, body_req) }
connection.connect()