Method failed: (/rest/api/2/issue) with code: 400 when creating an Issue

I have been successfully querying projects and issues from JIRA. but i get an error when i try to create an Issue. Below is the data that i am trying to post to rest/api/2/issue endpoint

 

"{\"fields\":{\"description\":\"test\",\"issuetype\":{\"name\":\"Bug\"},\"project\":{\"key\":\"TSTB\"},\"summary\":\"this is a test\"}}"

 

Can anyone help identify what's wrong with the above syntax?

3 answers

1 vote

Your endpoint and data look fine to me. 

One quick check (although I'd expect a different error) - can you manually create the issue in the UI with the same data? 

Could you give us the line of code making the call, and the full error?

1 vote
Warren Levy Community Champion Aug 02, 2017

Hi Indira

Just to reassure you, I had been querying using the API for ages, then really struggled with my first issue creation.

Your JSON looks fine, so I don't think that that's the problem. Are there any required (mandatory) fields that you don't have in your JSON? This could result in an error.

Are you certain that you have an issue type of Bug?

Apart from the 400 code, what is the return message - it may give some indication as to what the problem is. 

What is the code and format that you're using in your Post?

Warren

Thank you Warren! Looks like the Priority field was mandatory. Once I set that, I was able to create the issue successfully.

Indira

Priority was a Mandatory field which had to be set in the JSON.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Agile

What is ChatOps? A guide to its evolution, adoption, and significance

I am the product of AIM. I can hear that door swinging open and closed in my mind with absolute fidelity. I’d recognize that ding anywhere. At 15, as I typed away into AOL IM, I never imagined that ...

39 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you