I want to build a listener, which uses a rest call to create a user in Jira.
But I always get a 400 error with this code, which gives me the impression, that the body is wrong for some reason (but for example creating a space in Confluence works with my code when i change up some parameters, so I'm not sure if it's a Jira related Problem.
def username = 'admin'
def password = 'adminpassword'
def paramsUser = [
"name": "Jojo",
"displayName": "Jojo of Atlassian",
"password": "abracadabra",
"emailAddress": "jojo@atlassian.com"
]
String httpString2 = 'https://company.test.company.cloud/rest/api/2/user'
URL url
url = new java.net.URL(httpString2)
def authString = username + ':' + password
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes())
String authStringEnc = new String(authEncBytes)
URLConnection connection = url.openConnection()
connection.setRequestProperty('Authorization', 'Basic ' + authStringEnc)
connection.setRequestMethod('POST')
connection.setRequestProperty('Accept', '*/*')
connection.setRequestProperty('Content-Type', 'application/json')
connection.setDoOutput(true)
connection.setDoInput(true)
def jsonInputString = JsonOutput.toJson(paramsUser)
OutputStream os = connection.getOutputStream()
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
def inputStream = connection.getInputStream().getText()
Anyone sees what I do wrong here?
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.