How to programmatically add several customers with assigned email and password

Amedeo Farello February 9, 2019

Hello, I need to migrate hundreds of customers from another help desk system. I would prefer to avoid telling them to re-register on the new Jira Service Desk portal.

I have learned that I can create a new customer without sending the invitation mail and then set his password, but I'm dealing with hundreds of them, is there a way to do this by using a CSV file?

1 answer

0 votes
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 9, 2019

Hi @Amedeo Farello

My approach is to use the rest api for this

https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/user-createUser

I use excel to load the csv. Then I use formulas i.e. concatenate to stitch together data and fixed snippets into a ‘curl’ command to call  the REST API for each row of data.

the results are just pasted into a command window.

Amedeo Farello February 9, 2019

Thank you @Tom Lister,

I am totally new to REST and curl. Should this be the shape of the resulting command?

curl --request POST \
  --url 'https://my-domain.atlassian.net/rest/api/2/user' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '"{\"name\":\"Fred\",\"email\":\"fred@example.com\",\"displayName\":\"Fred F. User\",\"password\":\"1234\"}"'

 

But then, how could I create multiple customers at once?

Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 9, 2019

Hi @Amedeo Farello

what format do you have your user data in?

i’ve used SQL in some cases e.g. for adding a user to a group

 SELECT *,
concat(
'curl -insecure -u admin:password -X POST --data "{\\"name\\": \\”',newval,'\\"}" -H "Content-Type: application/json" https://localhost:8080/rest/api/2/group/user?groupname=', parent_name
) as curl
FROM jiradb.groupmap
where user_name != newval

I’ve used excel by putting the fixed parts of the curl statement in static cells and creating a formula to turn each line of a sheet into a runnable command. Do you need more detail on that?

Amedeo Farello February 9, 2019

It would be nice, thank you!

Tom Lister February 9, 2019

Hi

If you open your csv data in excel so that your user data is in cols A,B,C,D for values of name, email, display-name, password

Put the surrounding clauses required in other cells

e.g. E1 contains 

curl --request POST \  --url 'https://my-domain.atlassian.net/rest/api/2/user' \  --header 'Accept: application/json' \  --header 'Content-Type: application/json' \  --data '"{\"name\":\"



F1 contains

\",\"email\":\"

 

etc for all the surrounding snippets

then in the next free cell on row 1 add a formula

=concatenate($E$1, A1, $F$1, A2   etc)

and so on to join all parts to form one command. The dollar values are fixed in place, the other values will change as you copy the formula down for the number of rows you have. This formula column can then be cut and pasted into a command window
 

Amedeo Farello February 9, 2019

Many thanks, I will try this approach.

Amedeo Farello February 11, 2019

The "/rest/api/2/user" API is not what I need, it creates (just as the name implies) users, not customers. I guess that what I need to use is the "/rest/servicedeskapi/customer" API, altough it does not seem to accept a 'password' field.

Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 11, 2019

Hi

There a free REST API Browser available from the marketplace that you can use to experiment with REST calls to figure out the functionality you'll get from each call

Amedeo Farello February 11, 2019

Hi,

I'm learning the hard way through PHP/Unirest calls. If I try to add a 'password' to the "Create customer" API, I get a huge series of Java exceptions.

I have read the documentation and it seems there is no way to create a customer along with his password.

Amedeo Farello February 11, 2019

But wait, there's more.

Customers created with the "/rest/servicedeskapi/customer" API appear into the "https://softing.atlassian.net/admin/jira-service-desk/portal-only-customers" page, but when they log in, they are not tied to any JSD project!

...And now the "https://softing.atlassian.net/admin/jira-service-desk/portal-only-customers" page shows the following error: "An unknown error has occurred trying to contact our servers, please try again. If the issue persists please raise a ticket with support."

...And it looks like I am not able to raise that ticket, probably because I'm still in the 7-days evaluating period.

Not at all a great experience until now...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events