How to create an issue using NodeJS and the Jira API - 2022

Adam Pitcher August 12, 2022

Hi All,  I know this is a duplicate topic but the other topics are quite old and I am just about out of my mind on this one.

Am trying to write an AWS Lambda to create a Jira issue at certain points in the year.   Should be pretty simple yes?   No.   I walked through the Jira docs, several blogs and tutorials and nothing is really helping me out here.   I am really hoping someone can just say - HEY STUPID (really I give you permission). Here is what you missed.

My call is as follows

await axios.post(encodeURI(`https://mycompanyurl/rest/api/3/issue`), {
headers: {
'Authorization': `Basic ${Buffer.from(
`myemailaddress:myjiratoken`
).toString('base64')}`,
Accept:'application/json',
'Content-Type':'application/json'
},
body: bodyData
}).then(res => {
console.log(`statusCode: ${res.status}`);
console.log(`Created = ${res.data.total}`);
total = res.data.total;
}).catch(error => {
console.log(error.response.status)
console.log(error.response.data)
});

and body Data is (again, super simple - not a lot of moving parts)

let bodyData = `{
"fields": {
"summary": "Test automated ticket",
"project": {
"id": "10058"
},
}'
}`


And i get back
2022-08-12T23:18:48.305Z 43c72edb-1897-4367-b652-6676593e70b7 INFO 400
2022-08-12T23:18:48.324Z 43c72edb-1897-4367-b652-6676593e70b7 INFO {
errorMessages: [],
errors: { project: 'Specify a valid project ID or key' }
}


That is my project ID - checked it out in the settings and checked it out in the page source

I am sure, as I said, it is dumb - but I have been going around with this thing all day so may be staring right at it, but am punting to the good people of the Atlassian community.

Thank you all
-Adam

1 answer

0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 13, 2022

Hello @Adam Pitcher 

Is the ID you have provided a valid project ID?

Have you tried submitting the project key instead?

Have you tried submitting the numeric project ID without the surrounding quotes?

Adam Pitcher August 15, 2022

Hi @Trudy Claspill , Thanks for the suggestion but yeah - tried all those.   Just baffling to me.   I am going to go a different way for this one and just have the lambda email an issue and use Jira to convert it.

I will have to figure it out later for an upcoming project, adding subtasks, but will deal with it again then.     It just does not make any sense.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events