’m trying to create an issue with jira-client - npm
for that I created a code snippet based on what a bare minimum body should be which I got from https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post
const issue = {
fields: {
summary: "Test for Jira utility",
issuetype: {
id: issueType
},
project: {
id: projectId
},
reporter: {
id:reporterId
},
}
}
jira
.addNewIssue(issue)
.then(result => {
console.log(result)
})
.catch(err => {
console.log(err)
})
where the issuetype is 10001 that is story
but while executing I’m getting
Error: {"errorMessages":[],"errors":{"issuetype":"The issue type selected is invalid."}}
at JiraApi.doRequest ((Redacted for obv reasons)\jira-util\node_modules\jira-client\lib\jira.js:347:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Why is this the case ?
Thank you in advance
Putting the issueType as 1 created an issue of type bug
Hi @Sebastian Krzewiński
I found the issue types from here Issue Id types
In my project I can see the main issues being Tasks and bugs. I tried both but getting
Error: {"errorMessages":[],"errors":{"issuetype":"valid issue type is required"}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
please could you share your call code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi sure,
var jira = new JiraApi({
protocol: "https",
host: (redacted),
bearer: (redacted),
});
jira
.getProject(projectId)
.then((project) => {
console.log(`Project: ${project.name}`);
})
.catch((err) => {
console.log(err);
});
jira
.getCurrentUser()
.then(user => {
console.log(`UserId: ${user.key}, \n User: ${user.name}`)
})
.catch((err) => {
console.log(err)
})
This gives me results,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
const issue = {
fields: {
project: {
id: projectId
},
summary: "Test for Jira utility",
issuetype: {
id: issueType
},
reporter: {
id:reporterId
}
}
}
jira
.addNewIssue(issue)
.then(result => {
console.log(result)
})
.catch(err => {
console.log(err)
})
@Fabio Racobaldo _Herzum_ This is the code block for issue creation I added
I use jira-client
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
please put the result of your code so that I can see the effective call
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Fabio Racobaldo _Herzum_
sorry, here are the results
PS <redacted>\jira-util> node .\index.js
Error: {"errorMessages":[],"errors":{"issuetype":"valid issue type is required"}}
at JiraApi.doRequest (<redacted>\jira-util\node_modules\jira-client\lib\jira.js:347:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
UserId: <redacted>,
User: rahim.ts
Project: <redacted>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Fabio Racobaldo _Herzum_ @Sebastian Krzewiński
I gave the issueId as just 1 and it worked. I don't know why but it did. But thank you for investing your time into it. Really appreciated
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Rahim T_S ,
welcome to the Atlassian community!
Please verify that you are adding the correct parameters for :
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fabio,
The project Id and the reporter Id are valid, I verified that by using them to getCurrentUser and getProject APIs and they give valid expected results
I got the issue types from here
Issue Id types
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Fabio Racobaldo _Herzum_
Yes it's valid. I checked now.
the main ones are Tasks and Bugs which are 10002 and 10004 respectively.
I tried both right now and I'm getting
Error: {"errorMessages":[],"errors":{"issuetype":"valid issue type is required"}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Rahim T_S Please check what issue type id you selecting. It sounds like you are trying to choose issue type which is not available in project.
Regards,
Seba
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.