import.java.net.HttpURLConnection
import java.net.URL
import java.util.Base64
URL url = new URL(http://crowd:8095/crowd/rest/usermanagement/1/user
con.setRequestMethod("POST")
def password = "password"
def username = "username"
def userpass = username + ":" + password
def basicAuth = "Basic:" + new String(Base64.getEncoder().encode(userpass.getBytes())
con.setRequestProperty("Authorization", basicAuth)
con.setRequestProperty(Content-Type", application/json; utf-8)
con.setRequestProperty("Accept", aplication/json)
con.setRequestProperty("Cache-Control","no-cache")
con.setRequestProperty("X-Atlassian-Token", "no-check")
con.SetDoOutput(true)
def body = "{\"name\": \"sampleuser\",\"password\":\"secret\",\"first-name\":\"sample\",\"last-name\":\"user\",\"display-name\":\"Sample User\",\"email\":\"sampleuser@user.cool\"}"
OutputStream os = con.getOutputStream()
byte[] input = body.getBytes("utf-8")
os.write(input,0,input.length)
log.warn(con.getResponseCode)
log.warn(con.getResponseMessage)
con.disconnect()
issue resolved. I replaced the body to
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.