Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unauthorized user creation through Scriptrunner REST API on cloud

Constance Hua (Private) August 10, 2018

I am trying to create a new user without any groups or any specificity, just a simple user.

I am a site administrator on Jira Cloud.

Here is what I tried on the script console:

def createUser = post("/rest/api/2/user")
.header('Content-Type', 'application/json')
.body([
emailAddress: 'email2@test.test',
name: 'testuser2',
displayName: 'test user2'
])
.asObject(Map)
if (createUser.status != 400) {
return createUser
}

 

Here is what the logs give me:

Serializing object into 'interface java.util.Map'
POST request to /rest/api/2/user returned an error code: status: 401 - Unauthorized
body: [errorMessages:[You are not authenticated. Authentication required to perform this operation.], errors:[:]]
POST /rest/api/2/user asObject Request Duration: 762ms

Thank you for your help!

1 answer

1 accepted

1 vote
Answer accepted
Kristian Walker _Adaptavist_
Community Champion
August 10, 2018

Hi Constance,

Thank you for your question.

I can confirm that the Create user rest API call which is documented inside of the API documentation here states that this rest call is not permitted to be made from APP's meaning that ScriptRunner for Jira Cloud will be unable to execute this rest call.

This means that currently inside of the cloud version it is not possible to create a script to programmatically create a user using ScriptRunner for Jira Cloud as we only support rest calls which are permitted apps being allowed to access the rest resource. 

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.

Regards,

Kristian

Constance Hua (Private) August 10, 2018

What a horrible news!

Thank you for you answer, that's the line I missed! 

If you have any idea on how to work around this please don't hesitate!

Best

Himanshu Raj Singh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 26, 2023

Hey do you have a scriptrunner script to create user in jira cloud ?

Suggest an answer

Log in or Sign up to answer