Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,796
Community Members
 
Community Events
184
Community Groups

Can't add users to crowd with rest API, getting Internal Server Error 500

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()
I've written the script as above, which should add a user crowd. However, when it runs I get response code 500 "Internal Server Error".
Any help would be appreciated thanks :) 

1 answer

1 accepted

0 votes
Answer accepted

issue resolved. I replaced the body to 

 
def body = "{\"name\":\"sampleuser\",\"password\":{\"value\":\"secret\"},\"active\":true,\"first-name\":\"Sample\",\"last-name\":\"User\",\"display-name\":\"SampleUser\",\"email\":\"sample@user.cool\"}"

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events