JIRA on creation of new issue

Hey mates,

today i was trying to create a new issue using REST API from JIRA and I always get the error:

HTTP/1.1 405 Method Not Allowed 

I am using OAuth authentication to create and edit issues. I already edit a few fields on issues that are already created, but now I am trying to create new issue.

URL

 https://xpto.pt/rest/api/2/issue/

 

JSON code

{
"fields": {
"project": {
"key": "ProjectKey"
},
"component": "CAIX - TEST 1",
"summary": "TESTE REQ. NAME",
"issuetype": {
"name": "Issue"
},
"labels": ["CASE-TEST", "REQUIREMENT", "Tests"]
}
}

 Note: i change the project key and page of JIRA for this example.

My url: 

My JIRA version is V7.1.9.

I already search and find that is another way to create issues using rest/api/2/issue/createmeta, but i dont want to use that.

 

Do you have any ideia of whats is wrong ? If necessary i can put put a example of the code.

1 answer

0 vote
Alexey Matveev Community Champion Oct 31, 2017

Hello,

REST API can send GET, POST, PUT, DELETE requests. Method Not Allowed usually means that you send a wrong request type. If you want to create an issue, it is a POST request. Make sure you make a POST request.

If the problem is not fixed kindly provide your code for making the request.

I already try the json example from JIRA API but the error still appears. See the code i am using

{
    "fields": {
       "project":
       { 
          "key": "TEST"
       },
       "summary": "REST ye merry gentlemen.",
       "description": "Creating of an issue using project keys and issue type names using the REST API",
       "issuetype": {
          "name": "Bug"
       }
   }
}


 

I Post via this code:

uri is the page: https://xpto.jira.com/rest/api/2/issue/

json2 is the example

 

HttpPut put = new HttpPut(uri);
HttpResponse response = null;
put.setHeader("Content-Type", "application/json");
put.setHeader("Authorization", "Basic " + args.getJiraAuthToken());
try {
HttpEntity entity = new ByteArrayEntity(json2.getBytes("UTF-8"));
put.setEntity(entity);
response = httpClient.execute(put);

}catch (Exception e){
System.out.println(e);
}finally {
return response;
}

 

 

 

Alexey Matveev Community Champion Oct 31, 2017

Replace new HttpPut(uri) with new HttpPost(uri)

Martin Varga Atlassian Team Oct 31, 2017

What @Alexej said. Also:

rest/api/2/issue/createmeta

is not used to create issues. This is the meta data documentation for the fields you are sending to the create endpoint. 

I already find the problem :)

Needed to change to HttpPost and need to change the IssueType.

 

@Martin Varga AND @Alexey Matveev Thanks for your help guys! If u need something from me, contact me :)

 

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 Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

620 views 6 12
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