I am building a NodeJS application from where I want to get project/issues from JIRA using REST APIs provided by JIRA. My jira is running on some server ('http://example.com:8080/secure/Dashboard.jspa') and I am able to use REST APIs from POSTMAN using BASIC AUTH to get all kind of data but when I tried to log in to JIRA using REST APIs and NodeJS, I am getting some response but I am not able to understand it how I am going to use that information to call other APIs.
What I am doing is, I am passing username and password as a command-line args then I am sending those creds to login to JIRA. Then I am going to use the 'node-fetch' package to get information from REST APIs.
Below is my code:
const fetch = require("node-fetch");
const yargs = require("yargs");
var JiraClient = require("jira-connector");
var request = require("request");
const jiraBaseUrl = "http://example.com:8080/secure/Dashboard.jspa";
const loginUrl = "auth/1/session";
const username = yargs.argv.u;
const password = yargs.argv.p;
const projectName = yargs.argv.n;
var headers = {
"Content-Type": "application/json"
};
var options = {
url: "http://example.com:8080/rest/api/2/issue/createmeta",
headers: headers,
auth: {
user: username,
pass: password
}
};
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
}
}
request(options, callback);
Can somebody please tell me what I am doing wrong or what do I need to do with the data I am getting in order to use other APIs like ('http://example.com:8080/rest/api/2/issue/10008')? Or am I doing something wrong to login?
I have read the documentation on the JIRA website but was not able to understand correctly.
http://example.com:8080instead. You can find this at example.com:8080/secure/admin/ViewApplicationProperties.jspa