REST API startup-help - create user

Hello everybody,

I need some way to get new users automatically onboarded and started to play around with the JIRA Cloud REST API but I need some help to get started.

So I need to get authenticated first to send API requests via REST, I’ve already generated an Token for that. And I’ve found the right POST request via curl for creating a new user account. My problem is to get those two combined.

So the curl command for authenticating looks like that:

curl -D- \
   -u user@domain.com:API_Key \
   -X GET \
   -H "Content-Type: application/json" \
   https://name.atlassian.net/rest/api/2/issue/createmeta

and the command for creating a new user:

curl --request POST \
  --url 'https://name.atlassian.net/rest/api/2/user' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "emailAddress": "new_user@domain.com",
  "displayName": "New User"
}'

If I try to authenticate with the first one (seems to work) and use the second command after that, it seems that I’m not authenticated anymore or it is a new session or something like that.

Some help would be appreciated :slight_smile:

Thanks!

Hi Ulrich,

you have to send the authentication information for each request you are performing. This means for your second request you have to add -u user@domain.com:API_Key \ as well. Does this work for you?

Please take care about this deprecation notice for Jira cloud regarding cookie based authentication if you have thought about to use it: https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/

1 Like

that worked! thanks a lot man!

Was too simple… I’ve got an error that I need a username, but that error was about creating the user not the authentication itself. Unfortunatly the documentation says that the username is not requiered.

Thanks again!

1 Like