Forums

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

can we create bulk users from csv in jira and confluence without using any Plugin ?

Anvesh Kagithaala August 15, 2019

I'm interested in creating bulk users in jira and confluence environments without purchasing plugin. Can you Please help me in this manner ... 

1 answer

0 votes
DPKJ
Community Champion
August 15, 2019

You can do that using rest API mentioned here,

For example if your CSV structure is like like this,

name,fullname,email,password

 

You can write simple BASH or any other programming script (python, pearl, php, node) to read CSV file and send POST to request to above mentioned API request.

DPKJ
Community Champion
August 15, 2019

Here is sample in node js (we used to use it 1 year back)

// This code sample uses the 'request' library:
// https://www.npmjs.com/package/request
var request = require("request");
//file stream
var fs = require("fs");
//csv parser
var parse = require("csv-parse");

var fileName = "users.csv";
var csvData = [];

fs.createReadStream(fileName)
.pipe(parse({ delimiter: ":" }))
.on("data", function(csvrow) {
//console.log(csvrow);
//do something with csvrow
csvData.push(csvrow);
})
.on("end", function() {
//do something wiht csvData
//console.log(csvData);
});

csvData.forEach(function(data) {
var bodyData = `{
"password": "${data.password}",
"emailAddress": "${data.email}",
"displayName": "${data.fullname}",
"name": "${data.name}"
}`;
console.log(data);
console.log(bodyData)

var options = {
method: "POST",
url: "<JIRA_BASE_URL>/rest/api/2/user",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: bodyData
};

request(options, function(error, response, body) {
if (error) throw new Error(error);
console.log(
"Response: " + response.statusCode + " " + response.statusMessage
);
console.log(body);
});
});
Like Deepanshu Natani likes this

Suggest an answer

Log in or Sign up to answer