Forums

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

“issuetype”:”The issue type selected is invalid.”

Rahim T_S
Contributor
January 10, 2023

’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

4 answers

1 accepted

0 votes
Answer accepted
Rahim T_S
Contributor
January 11, 2023

Putting the issueType as 1 created an issue of type bug

0 votes
Rahim T_S
Contributor
January 11, 2023

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"}}


Fabio Racobaldo _Herzum_
Community Champion
January 11, 2023

please could you share your call code?

Rahim T_S
Contributor
January 11, 2023

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,
Rahim T_S
Contributor
January 11, 2023
  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
Fabio Racobaldo _Herzum_
Community Champion
January 11, 2023

please put the result of your code so that I can see the effective call 

Rahim T_S
Contributor
January 11, 2023
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>
Rahim T_S
Contributor
January 11, 2023

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

0 votes
Fabio Racobaldo _Herzum_
Community Champion
January 11, 2023

Hi @Rahim T_S ,

welcome to the Atlassian community!

Please verify that you are adding the correct parameters for :

  • issue type id
  • project id
  • reporter username

Fabio

Rahim T_S
Contributor
January 11, 2023

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 

Fabio Racobaldo _Herzum_
Community Champion
January 11, 2023

Hey @Rahim T_S ,

are you sure that issue type is in your Issue Type Scheme for your project?

Fabio

Rahim T_S
Contributor
January 11, 2023

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"}}

0 votes
Sebastian Krzewiński
Community Champion
January 10, 2023

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events