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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Multiple Organization creations with one API call

Hi ,

 

I am trying to create several organizations with one api call but keep getting the 404 error. 

Whilst I understand this has been raised a few times it was mentioned in the below post or hinted at this can be done.

https://community.atlassian.com/t5/Jira-Service-Desk-questions/How-to-bulk-import-oganizations-in-my-projects/qaq-p/1341574

 

Can this be done and if it can how as I have tried all sorts of different ways to no luck.

1 answer

1 accepted

0 votes
Answer accepted

Hi @daniel 

You can use the API endpoint to bulk create those several organizations.

Can you give an example of how to create multiple organisations with 1 API call.

I can create using the API endpoint but currently have to do one call at a time, I might as well create it one at a time within the Helpdesk itself if I can't create several in 1 api call.

Hi @daniel 

You can create a csv file with a single column of the organization name as much as you want and use this shell script to run every name in a loop. it's a simple script that does it in one go.

#!/bin/bash
# create JSD Org's Script
IFS=","
OLDIFS=$IFS
read -p "Enter your Atlassian Email Address: " email
read -p "Enter your Atlassian API token: " token
# format : nexusfive not complete URL
read -p "Enter Atlassian Instance Name (e.g. nexusfive) : " ins_name
# Declare file path, using current directory
read -p "Enter the CSV File Name: " makefile
content="Content-Type: application/json"
function createOrg {
echo "Reading CSV File...Please wait"
cat $makefile | while read -r org
do
if [[ -n "$org" ]]; then
curl -s -u "$email":"$token" -d '{"name": "'$org'"}' -X POST -H "$content" "https://${ins_name}.atlassian.net/rest/servicedeskapi/organization"
echo -e "Organization $org created"
else
echo -e "Something went wrong, cannot create $org..." >> fail.txt
fi
done < $makefile
}
createOrg
echo -e "Creation Complete..."
IFS=$OLDIFS

Save the file as an .*sh extension and use. if you're on window use the Cygwin software or the Linux bash App from the Marketplace.

Hi, Thats brill thanks for this.

 

I have managed to run the script, however whilst it states Creation complete, they are not actually created in the helpdesk.

I would expect the below to appear before the creation complete echo

echo -e "Organization $org created"

 

Any ideas on where it could be going wrong? I am not getting any more errors?

After running here is the response:-

 

Enter your Atlassian Email Address: ballingerdaniel@mail.com

Enter your Atlassian API token: Token

Enter Atlassian Instance Name (e.g. nexusfive) : gloucester4894

Enter the CSV File Name: org upload.csv

Reading CSV File...Please wait

Creation Complete...

Hey @daniel 

The problem is on line 10

Enter the CSV File Name: org upload.csv

the filename should not have space in it as the script doesn't validate anything. so you could rename the filename to org_upload.csv or upload.csv for simplicity and try again.

Hi, I have changed the file to just upload.csv and still get the same problem?

Any other ideas?

Don't need to add anything else to the csv file?

Like 

 

Col1.        Col2.        Col3

Value.      Test1        Test2

Hi @daniel 

Your CSV file should look like this with only a single column e.g:

col
Name 1
Name 2
Name 3

That's how the format should be

Ok I get 2 types of errors

 

The first is that when I save from excel to csv file its not putting the commas in. 

Reading CSV File...Please wait

{"errorMessages":["Illegal unquoted character ((CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value\n at [Source: org.apache.catalina.connector.CoyoteInputStream@325b19f4; line: 1, column: 20]"]}Organizati created000

Creation Complete..

 

If I open in a text editor to add in the commas I get the following error:-

{"errorMessages":["Unexpected end-of-input in VALUE_STRING\n at [Source: org.apache.catalina.connector.CoyoteInputStream@36176546; line: 1, column: 37]"]}Organi createdake4000,

this error looks like it prevents any or the preceding ones from being created

Hi @daniel 

Since it's just a single column, you don't actually need a comma just create a file in a text editor with each name in a new line and save as .csv file as mentioned in my previous comment.

@Prince Nyeche If I remove the commas I get the error :-

{"errorMessages":["Illegal unquoted character ((CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value\n at [Source: org.apache.catalina.connector.CoyoteInputStream@325b19f4; line: 1, column: 20]"]}Organizati created000

 

so not sure now how to get the CSV file to upload correctly 

@Prince Nyeche Ok I have now managed to get it working.

The format I used was the below:-

Cat1
,
Cat2
,
Cat3


Not sure why it won't work without the comma and it does throw an error when processing the comma but it now puts these into the Helpdesk

:-) Happy now  

 

Now to add them to the Helpdesk and then add the customers

Hi @daniel 

Interesting, the script's IFS requires a comma that's why it looks for it. On unix systems this shouldn't be a problem for only a single column, however depending on what os system you're using I think it had to do with the CR (carriage return) or LF (line feed) or a combination as the data should just be on a new line but glad to know it works now when a comma was used in the new line. Have a nice day ahead 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Asked in Jira Service Desk

Calling all Mindville Insight users, we need your help! (there might be swag involved)

Hello Insight users,  As part of our (Mindville's) acquisition by Atlassian, our training team is looking to build some new Insight training materials and we want to hear from you!  ...

276 views 4 6
View question

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you